Hi everybody,
I have an equation which I need to solve for a large iteration. It takes too many time, I have still waited for it since yesterday to solve.
So is there any solution to solve it faster.
Thank you
for i=1:1:18858
c(i,1)=(a(i,1)/b(i,1));
d(i,1)=(((x+1)*exp(x)))-c(i,1);
y(i,1)=solve(d(i,1),x);
end

 채택된 답변

Roger Stafford
Roger Stafford 2017년 11월 11일

0 개 추천

Assuming you have the ‘lambertw’ function on your Matlab system:
d = a./b;
e1 = exp(1);
y = zeros(1,18858);
for ix = 1:1:18858
y(ix) = lambertw(e1*d(ix))-1;
end

댓글 수: 4

Muhammed Ekin
Muhammed Ekin 2017년 11월 11일
Thank you for your response. But it is not exp(1). I am looking for response of (x+1)*exp(x)-c(i,1).
I have given you the solution in terms of the 'lambertw' function of your equation. Use 'solve' on your equation and see.
Muhammed Ekin
Muhammed Ekin 2017년 11월 11일
I have already used 'solve' as you see in my question.
If you look at “https://www.mathworks.com/help/symbolic/lambertw.html”, you will see that the lambertw function is the solution to the equation
w*exp(w) = k
namely, w = lambertw(k). In your equation, (x+1)*exp(x) = a/b, substitute w = x+1 and get
(x+1)*exp(x) = w*exp(w-1) = w*exp(w)/exp(1) = a/b
Therefore
w*exp(w) = exp(1)*a/b
Consequently
x = w-1 = lambertw(exp(1)*a/b)-1;
There! I've done a 'solve' for you.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Muhammed Ekin
Muhammed Ekin 2017년 11월 12일

0 개 추천

Thank you although it is slow and give same results to mine, that is another way to solve it.

질문:

2017년 11월 11일

답변:

2017년 11월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by