Solve function is unable to find an explicit solution

This is my code. It is not there entirely.It is almost like this.
clc;
% Read image
I=imread('03022017_subset.tif');
sigma0_VH=I(:,:,1);
sigma0_VV=I(:,:,2);
LIA=I(:,:,3); %Local Incidence angle
[m,n,p]= size(I);
er=sym('er',[m,n]); % declaring dielectric constant as symbolic variable matrix
o=ones(m,n);
L=4;
pow=10;
x=0;
s=0.5;
w=((pi.*(L.^(2)))./pow).*(exp(-(((L.^(2)).*((((2.244.*sind(LIA).*cosd(x))-(1.121997.*(sind(LIA)))).^2)+((2.244.*sind(LIA).*sind(x)).^2))))./(4.*pow)));
SIvv=symsum(Ivv,z,1,Inf);
eqsigmavv=sigma0_VV-((1.258877268./4.*pi).*(exp(-2.*1.258877268.*(s.^2).*((cosd(LIA)).^2))).*((abs(SIvv)).^2).*(w./factorial(pow)))==0;
dcvv=solve(eqsigmavv,er);
solve function of 'dcvv' returning an answer of 1 by empty. But it is not what expected to get. The value of eqsigmavv is very lengthy. It is showing truncated in display. And some variable 'r' which is never declared in the programe is also included in it.

7 Comments

We do not know what Ivv is.
Your expression being solved for does not contain the variable being solved for.
You should never use non-trivial floating-point constants with solve(). You have
(1.258877268./4.*pi)
as part of your expression. How is that intended to be interpreted? Is that intended to be 1258877268 / 1000000000 / 4, exactly, multiplied by the indefinitely precise transcendental value pi ? Is it intended to be "take the nearest representable binary floating point number to 1.258877268, divide that by 4, an operation which just happens to preserve the same number of digits in binary floating point, and do a binary floating point multiplication by the nearest representable binary floating point number to the transcendental value pi, letting the multiplication round-off fall however it happens to, and use that mathematically uncertain binary floating point value in the rest of the calculation?
Is it even divide by 4 and multiply by pi that you want, or do you want to divide by (4 times pi) ?
Remember that solve() is to try to find exact closed form solutions, indefinitely precise -- to try to find theoretical solutions. It is a mistake to ask for the theoretical solution to an expression whose value you cannot even predict the value of.
I replaced pi with (4.*3.14159).Still it is not working. Same problem again.
We do not know what Ivv is.
Your expression being solved for does not contain the variable being solved for.
We are not able to test on your behalf.
I=imread('03022017_subset.tif');
sigma0_VH=I(:,:,1);
sigma0_VV=I(:,:,2);
ter=sym('ter',[3,3]); % declaring dielectric constant as symbolic variable matrix
to=ones(3,3);
LIAT=[37.760056,36.951263,36.990906;37.904781,37.156265,37.195721;38.194260,37.566406,37.605480];
% Equation for Ft
tRv0=(to-sqrt(ter))./(to+sqrt(ter));
tFt=8*(tRv0.^2) .*((sind(LIAT)).^2).*((cosd(LIAT)+(sqrt(ter-(sind(LIAT)).^2)))./(cosd(LIAT).*(sqrt(ter-(sind(LIAT).^2)))));
tSt0=(abs(to+((8.*tRv0)./(tFt.*cosd(LIAT))))).^(-2);
L=4;
pow=10;
x=0;
s=0.5;
tw=((pi.*(L.^(2)))./pow).*(exp(-(((L.^(2)).*((((2.244.*sind(LIAT).*cosd(x))-(1.121997.*(sind(LIAT)))).^2)+((2.244.*sind(LIAT).*sind(x)).^2))))./(4.*pow)));
% Equation for St
syms tz;
tStn=symsum(((((1.121997.*s.*cosd(LIAT)).^(2.*tz))./(factorial(tz))).*tw),tz,1,Inf);
tStd=symsum(((((1.121997.*s.*cosd(LIAT)).^(2.*tz))./(factorial(tz))).*(((abs((tFt)+(((2.^(pow+2)).*tRv0./((exp((1.121997.*s.*cosd(LIAT)).^(2))).*cosd(LIAT)))))).^(2)).*tw)),tz,1,Inf);
tSt=(((abs(tFt)).^2).*tStn)./tStd;
tRv=(cosd(LIAT)-sqrt(ter-(sind(LIAT)).^2))./(cosd(LIAT)+sqrt(ter-(sind(LIAT)).^2));
tRtv=tRv+((tRv0-tRv).*(to-(tSt./tSt0)));
tfvv=2.*tRtv./cosd(LIAT);
tTv=to+tRtv;
tTvm=to-tRtv;
tsq=sqrt(ter-(sind(LIAT)).^2);
tFvv=(((((sind(LIAT)).^2)./cosd(LIAT))-(tsq./ter)).*(tTv.^2))-(2.*((sind(LIAT)).^2).*((to./cosd(LIAT))+(to./tsq)).*tTv.*tTvm)+(((((sind(LIAT)).^2)./cosd(LIAT))+(ter.*(to+(sind(LIAT)).^2)./tsq)).*(tTvm.^2));
syms tz;
tIvv=((2.*1.121997.*s.*cosd(LIAT)).^tz).*tfvv.*(exp(-1.*1.258877268.*(s.^2).*((cosd(LIAT)).^2)))+((1.121997.*s.*cosd(LIAT)).^tz).*tFvv;
tSIvv=symsum(((abs(tIvv)).^2).*tw./factorial(tz),tz,1,10);
tsigma0_VV=[0.11262583,0.86308515,1.1438491;0.14032036,1.0475565,1.6186293;0.21424975,0.61734170,0.90188682];
teqsigmavv=tsigma0_VV-((1.258877268./(4.*3.14159)).*(exp(-2.*1.258877268.*(s.^2).*((cosd(LIAT)).^2))).*(tSIvv))==0;
tdcvv = solve(teqsigmavv,ter,'IgnoreAnalyticConstraints',1);
This is the entire code
I think I will need the .tif for testing.
You did not answer my questions about how you intend your floating point constants to be interpreted: do you intend them to be interpreted as implicit rationals in base 10, or do you intend them as implicit rationals in base 2 (which is how floating point is stored internally) ?
If you had the floating point constant 0.333333 in your code, would you intend that to represent the rational 1 divided by 3, or would you intend it to represent the rational 333333 divided by 1000000, or would you intend it to represent the rational 3002396749180579 divided by 9007199254740992 ? These choices matter when you are using solve(), since solve() asks for the exact solution, and it is a mistake to ask for the exact solution for an expression with vague input values.
Perhaps you should be using vpasolve()
I tried vpasolve. It is also giving 0 by 1 as solution.

Sign in to comment.

Answers (2)

This is the image.I want to represent 1/3 as 0.3333
Image is unable to attach. Can you please try it with following matrix.
ter=sym('ter',[3,3]);
to=ones(3,3);
LIAT=37.760056,36.951263,36.990906;37.904781,37.156265,37.195721;38.194260,37.566406,37.605480];
tRv0=(to-sqrt(ter))./(to+sqrt(ter)); tFt=8*(tRv0.^2) .*((sind(LIAT)).^2).*((cosd(LIAT)+(sqrt(ter-(sind(LIAT)).^2)))./(cosd(LIAT).*(sqrt(ter-(sind(LIAT).^2)))));
tSt0=(abs(to+((8.*tRv0)./(tFt.*cosd(LIAT))))).^(-2);
% surface roughness spectra W(n)
L=4; pow=10; x=0; s=0.5;
tw=((pi.*(L.^(2)))./pow).*(exp(-(((L.^(2)).*((((2.244.*sind(LIAT).*cosd(x))-(1.121997.*(sind(LIAT)))).^2)+((2.244.*sind(LIAT).*sind(x)).^2))))./(4.*pow)));
% Equation for St syms tz; tStn=symsum(((((1.121997.*s.*cosd(LIAT)).^(2.*tz))./(factorial(tz))).*tw),tz,1,Inf);
tStd=symsum(((((1.121997.*s.*cosd(LIAT)).^(2.*tz))./(factorial(tz))).*(((abs((tFt)+(((2.^(pow+2)).*tRv0./((exp((1.121997.*s.*cosd(LIAT)).^(2))).*cosd(LIAT)))))).^(2)).*tw)),tz,1,Inf); tSt=(((abs(tFt)).^2).*tStn)./tStd;
tRv=(cosd(LIAT)-sqrt(ter-(sind(LIAT)).^2))./(cosd(LIAT)+sqrt(ter-(sind(LIAT)).^2)); tRtv=tRv+((tRv0-tRv).*(to-(tSt./tSt0)));
tfvv=2.*tRtv./cosd(LIAT);
tTv=to+tRtv; tTvm=to-tRtv; tsq=sqrt(ter-(sind(LIAT)).^2); tFvv=(((((sind(LIAT)).^2)./cosd(LIAT))-(tsq./ter)).*(tTv.^2))-(2.*((sind(LIAT)).^2).*((to./cosd(LIAT))+(to./tsq)).*tTv.*tTvm)+(((((sind(LIAT)).^2)./cosd(LIAT))+(ter.*(to+(sind(LIAT)).^2)./tsq)).*(tTvm.^2));
syms tz; tIvv=((2.*1.121997.*s.*cosd(LIAT)).^tz).*tfvv.*(exp(-1.*1.258877268.*(s.^2).*((cosd(LIAT)).^2)))+((1.121997.*s.*cosd(LIAT)).^tz).*tFvv; tSIvv=symsum(((abs(tIvv)).^2).*tw./factorial(tz),tz,1,10);
tsigma0_VV=[0.11262583,0.86308515,1.1438491;0.14032036,1.0475565,1.6186293;0.21424975,0.61734170,0.90188682];
teqsigmavv=((tsigma0_VV-((1.258877268./(4.*3.14159)).*(exp(-2.*1.258877268.*(s.^2).*((cosd(LIAT)).^2))).*(tSIvv)))==0);
tic tdcvv = vpasolve(teqsigmavv,ter);
toc

13 Comments

That code did not work: you use tz before you define it, because the first "syms tz" is commented out.
I have a created a cleaned up version for my own use, but even just creating the teqsigmavv array is fairly slow and creates rather large sub-expressions, so I have no progressed towards a solution yet.
Why do you have so many "magic numbers" ? Is the 1.121997 from the assignment to tStn intended to be the same number as the 1.121997 from the assignment to tStd ? If you intend them to be the same value then why not assign to a variable (with a meaningful name) and use the variable? Why use 3.14159 in one place but pi in a different place?
1.121997 is a constant for this particular image. I applied directly in the equation. I think there is a problem in the line: tRtv=tRv+((tRv0-tRv).*(to-(tSt./tSt0))); solution given by this equation contains some unexpected variables (r and n)
This is a solution:
tRtv(1,1)
ans =
((ter1_1^(1/2) - 1)/(ter1_1^(1/2) + 1) - ((ter1_1 - 6755037812346739/18014398509481984)^(1/2) - 1780232650527177/2251799813685248)/((ter1_1 - 6755037812346739/18014398509481984)^(1/2) + 1780232650527177/2251799813685248))*((51375416058454120524490299147421638592250773504*abs((18014398509481984*(ter1_1^(1/2) + 1)*(ter1_1 - 6755037812346739/18014398509481984)^(1/2))/(6755037812346739*((ter1_1 - 6755037812346739/18014398509481984)^(1/2) + 1780232650527177/2251799813685248)*(ter1_1^(1/2) - 1)) - 1)^2*abs((ter1_1 - 6755037812346739/18014398509481984)^(1/2) + 1780232650527177/2251799813685248)^2*abs(ter1_1^(1/2) - 1)^4*((4685593773734083*exp(63834711222653326585719000350569/324518553658426726783156020576256))/1125899906842624 - 4685593773734083/1125899906842624))/(14849716343180055507990398757828129180178400307*abs(ter1_1 - 6755037812346739/18014398509481984)*abs((36893488147419103232*ter1_1^(1/2) - 36893488147419103232)/(8668920821841493*ter1_1^(1/2) + 8668920821841493) - ( *6755037812346739\\\r\n*((ter1_1 -* 6755037812346739/18014398509481984)^(1/2) + 1780232650527177/2251799813685248)*(ter1_1^(1/2) - 1)^2)/(1780232650527177*(ter1_1^(1/2) + 1)^2*(ter1_1 - 6755037812346739/18014398509481984)^(1/2)))^2*abs(ter1_1^(1/2) + 1)^4*(exp(63834711222653326585719000350569/324518553658426726783156020576256) - 1)) - 1) - ((ter1_1 - 6755037812346739/18014398509481984)^(1/2) - 1780232650527177/2251799813685248)/((ter1_1 - 6755037812346739/18014398509481984)^(1/2) + 1780232650527177/2251799813685248)
Also solutions are very lengthy. simplify() is not working.
The \r and \n are a display artifact that was present for two releases. They are not present in the solutions.
The formulae you are creating are lengthy; from what I have had time to look at them so far, I would be surprised if they simplified much at all. vpa() of them helps but not a great deal.
That means there is no solution for a lengthy equation??
I do not know yet. The expressions are very long and I need to dump them in another form to examine them. Unfortunately I encountered a MATLAB bug when I tried to write them to a file, so I am tracking that down.
Evaluating the expressions is quite slow :(
Are there any constraints, or any known approximate solutions?
There might be a solution near
2.3776380743291412, 4.57922901206987465, 5.12721985066769914
2.5428861799963518, 4.99485307456000971, 6.1037728919093297
2.52819244755165062, 3.88740304028682537, 4.61509374970096165
The fit residue is less than 0.01, but it can probably be improved.
However, at this stage it is still possible that there is no actual solution: it is possible at the moment that the equations cannot quite be satisfied. With all of those floating point numbers you used, it would not surprise me if there is a little inconsistency.
The supposed solution is between 20 and 90.How did u manage to get some solution? Is there any way to convert all the fractions in intermediate solutions to decimals of low precision?
Better:
2.09649681350695083, 4.50435086668072326, 5.1395572641299383
2.23998865052792961, 4.92781452233381057, 6.09661422366582606
2.57200339686864421, 3.87906966788711571, 4.59430513953129172
Residue is about 1E-7. Positions are starting to become more stable, but there is still available movement in the third decimal place.
"The supposed solution is between 20 and 90"
I take it you mean that range for each of the components. (Those look like degrees.)
The current best is
2.09709604796099 4.50416311903167 5.13972517382966
2.23993468989617 4.92827673574497 6.09692311640926
2.57220155453702 3.87915558359583 4.59424430929357
which has a residue about 1.4E-12 -- so at that point it is pretty much doing fitting against accidental round-off error.
"How did u manage to get some solution?"
I used a program that I am developing, but which is not ready to be shown to anyone else. These calculations were very slow and I had to tune the program down to use a do a fairly coarse search to try to find areas to look at more carefully.
Slightly better (at least for my implementing function):
2.09709586957955585, 4.50416224972559576, 5.13972527850544925
2.23993701810814461, 4.92827672315921195, 6.09692340175298675
2.57220009290275931, 3.87915792241145541, 4.59424410673230277
I tested with the range 20 to 90 as bounds, and all of the entries except possibly the first two quickly pinned themselves against the 20 lower bound (it looked like one of the first two might perhaps have been marginally different than 20 for the minimum value under the circumstance that all of the other values were 20.)
With that code, there is no way that there is a solution with any of the components required to be as large as 20.
I finally solved it. The symbolic matrix ter is converted to a single symbolic variable and for finding tdcvv a for loop is constructed.Still the values are not the expected.Almost same as what you got. Now I am working on it.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!