필터 지우기
필터 지우기

how to solve the following equation by using Matlab

조회 수: 1 (최근 30일)
Aisha Mohamed
Aisha Mohamed 2023년 1월 19일
댓글: Torsten 2023년 1월 22일
Hi all
When we solved this equation \begin{align}
f(z)=(0.10-0.3i) z^{-1} + (0.2121 - 0.0008i) z^{-2} +(0.9+0.001i)z^{-3}=0
by using Matlab, we got the following result ,
numerical solution by Matlab,
1/z_1= (0.0000 + 0.0000i)
1/z_2= (-0.4716 - 0.4706i)
1/z_3=(0.2359 + 0.4717i)
and when I solve this equation byhand we got;
1/z_1= 0.0000 + 0.0000i
1/z_2=(-0.4929597603-0.4990725263i)
1/z_3=(0.2561831187+0.5002232656i)
My questionis is,
By using the Matlab, How can I repeat the solution ( for example 100 times ) to check that every time the numerical solution still close to the solution that I have got by hand or become different?
By other way can I use any loop to repeat the solution 100 time by using the Matlab?
I appreciate any help
Thanks

채택된 답변

Luca Ferro
Luca Ferro 2023년 1월 19일
Try with this function:
function checksol(N) %N is the number of times it will solve the equation (dont use a huge number, 10 is sufficient)
syms z ;
sol={};
diffcount=0;
eq= (0.10-0.3i)* z^-1 + (0.2121 - 0.0008i) *z^-2 +(0.9+0.001i)*z^-3==0;
lastsol=solve(eq,z);
for jj=1:N
currsol=solve(eq,z);
if currsol ~= lastsol
diffcount=diffcount+1; %augments counter for every time it finds a different solution
end
lastsol=currsol;
end
if diffcount~=0
disp('Different result detected')
else
disp('Result is always the same')
end
end
On my machine it resolves it consistently, i would double check your by hand solution rather than matlab.
  댓글 수: 1
Aisha Mohamed
Aisha Mohamed 2023년 1월 20일
Thanks Luca Ferro
I am trying to run this function, but I did not find any resopnd from the Matlab .
I appreciate any help

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

추가 답변 (1개)

John D'Errico
John D'Errico 2023년 1월 20일
Your problem is:
f = @(z) (0.10-0.3i)*z.^(-1) + (0.2121 - 0.0008i)*z.^(-2) +(0.9+0.001i)*z.^(-3);
Please don't use curly braces in an equation. That is not valid MATLAB syntax. As well, MATLAB uses * to multiply. There is no implicit multiplication by a constant. MATLAB finds the solutions as:
syms Z
zsol = solve(f(Z),Z,'maxdegree',3)
zsol = 
The solution you claim to have found using MATLAB is a spurious one, since z == 0 is a divide by zero. So z = 1/0 is NOT a solution to that equation, even though you find it by substituting z = 1/u, and then solving for the roots using u. Sorry. There are only TWO solutions.
vpa(zsol)
ans = 
And what are the inverses ofthose numbers, so we can compare it to what you claim to have found using MATLAB?
1./vpa(zsol)
ans = 
And that is the same thing that MATLAB returns.
We can verify these are indeed the true solutions to the problem you show.
f(vpa(zsol))
ans = 
So numbers on the order of 1e-40. Since this is the default number of digits for vpa, that is just floating point trash.
Is there any meaningful reason to perform this solution a million times, or even just 100? NO. These are the solutions, and they don't change with time.
Anyway, are the solutions you claim to have found by hand really solutions to the problem you show?
z2invclaimed = -0.4929597603-0.4990725263i;
f(1/z2invclaimed)
ans = 0.0240 - 0.0130i
So not in fact a solution. It is close. You have made approximations, truncating results to only a few significant digits, so your claimed to be solutions that you found by hand are only approximate solutions. Effectively, they are solutions to approximately the problem you have written down.
Again, repeating the solution as many times as you wish will not matter. The result will not change.
  댓글 수: 2
Aisha Mohamed
Aisha Mohamed 2023년 1월 22일
Thank you very much.
This numerical solution is very accuracy.
The question is why the numerical solution is more accuracy than the solution the we have got manually? is this make sense?
Thanks for any help
Torsten
Torsten 2023년 1월 22일
The question is why the numerical solution is more accuracy than the solution the we have got manually? is this make sense?
Didn't John D'Errico try to answer this with his last sentences ?
You have made approximations, truncating results to only a few significant digits, so your claimed to be solutions that you found by hand are only approximate solutions. Effectively, they are solutions to approximately the problem you have written down.
And ? Did you cut digits from the polynomial coefficients for the numerical solution ?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by