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

답변 (1개)

Walter Roberson
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.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by