Dear all I wrote a program to solve an algebraic equations but the code it takes a long time and gives empty results. Is there any different idea to solve the equation?
1 次查看(过去 30 天)
显示 更早的评论
Dear all
I wrote a program to solve an algebraic equations but the code it takes a long time and gives empty results, so is there any different idea to solve the equation. The code is shown blow
clear all; clc
syms R i
d=1:3;
f=1-exp(-(R).^4.*(1+d.*(2*i+1)).^4);
for L=1:4
eval(sprintf('Pc_L%d = 1-symprod(f,i,0,L)', L));
end
for L=1:4
solve(eval(sprintf(' Pc_L%d- 0.9 == 0', L)),R)
end
0 个评论
回答(1 个)
Walter Roberson
2015-11-25
Your d is a vector so your f is a vector. You symprod() f with respect to i from 0 to L. What result are you expecting when you symprod? Are you expecting a vector of 3 results, one for the case where d = 1, one for the case where d = 2, one for the case where d = 3 ? I do not know if symprod is able to do that.
Using 'i' as the name of a variable is risky, especially in combination with symbolic computations, as 'i' is the name used for the imaginary unit, sqrt(-1) . You should use a different variable name. Not 'j' either.
You are not assigning the output of solve() to anything. The results are likely to not be very readable, so you should probably assign them to variables for later examination.
You are asking to solve(), which requests to find all closed-form solutions if any can be found. However, when solve() cannot find a closed-form solution, it silently switches to doing a numeric solve, and numeric solving looks for one numeric solution with no constraint about which of the numeric solutions it will look for.
You should probably be adding assumptions on R to avoid complex values (if you do not want them), or to avoid non-negative values. If you want numeric solutions then you should switch to vpasolve(), especially if you can supply a range of values to examine.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!