Warning: Equation solved, but no element can be extracted from the solution set.

Hi all:
I am new to symbolab and have encountered an error with the solve function:
Warning: Equation solved, but no element can be extracted from the solution set.
There is indeed a solution that I have found via optimization. But for future work I'd rather use symbolab.
Below is the code. Not many lines at all! Thanks in advance.
N = 2000000/2.5;
W = 70000;
t = 600;
ra = 45000;
pK = 1;
alp = 0.14;
gam = 0.6;
g = 0.0005;
tht = 3;
gg = alp*(1-gam);
syms x d real
nfun(x,d) = x*(tht*ra/gg) / (W-t*d)^(1/gg) * (W-t*x).^((1-gg)/gg);
n2fun = int(nfun,x,0,d);
d0 = solve(n2fun == N,d,'PrincipalValue',true);

 Respuesta aceptada

tic
Q = @(v) sym(v);
N = Q(2000000)/Q(2.5)
N = 
800000
W = Q(70000)
W = 
70000
t = Q(600)
t = 
600
ra = Q(45000)
ra = 
45000
pK = Q(1)
pK = 
1
alp = Q(0.14)
alp = 
gam = Q(0.6)
gam = 
g = Q(0.0005)
g = 
tht = Q(3)
tht = 
3
gg = alp*(1-gam);
syms x d real
nfun(x,d) = x*(tht*ra/gg) / (W-t*d)^(1/gg) * (W-t*x).^((1-gg)/gg);
n2fun = int(nfun,x,0,d);
sold = solve(n2fun == N, d, 'returnconditions', true)
sold = struct with fields:
d: [1×1 sym] parameters: [1×1 sym] conditions: [1×1 sym]
cparts = children(sold.conditions)
cparts = 1×3 cell array
{1×1 sym} {1×1 sym} {1×1 sym}
digits(50)
%cparts{1} is in(x, 'real')
%cparts{2} is roots of a degree 132 polynomial
%cparts{3} is conditions that simplify to -18806/5 <= x
csol = vpasolve(cparts{2})
csol = 
lb = lhs(simplify(cparts{3}))
lb = 
mask = simplify(imag(csol) == 0 & lb - 1e-50 <= real(csol));
d_solutions = csol(mask)
d_solutions = 
toc
Elapsed time is 17.998978 seconds.
The conditions found for the original solve() include a lower-bound -18806/5 <= x and that is exactly the value for the first 7 values. However due to round-off, the numeric values csol(1:7) - lb differ by up to +/- 1e-54 (assuming digits 50), so I introduce a tolerance of 1e-50 into the comparison.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by