how to solve the following equation by using Matlab

2 visualizaciones (últimos 30 días)
Aisha Mohamed
Aisha Mohamed el 19 de En. de 2023
Comentada: Torsten el 22 de En. de 2023
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

Respuesta aceptada

Luca Ferro
Luca Ferro el 19 de En. de 2023
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 comentario
Aisha Mohamed
Aisha Mohamed el 20 de En. de 2023
Thanks Luca Ferro
I am trying to run this function, but I did not find any resopnd from the Matlab .
I appreciate any help

Iniciar sesión para comentar.

Más respuestas (1)

John D'Errico
John D'Errico el 20 de En. de 2023
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 comentarios
Aisha Mohamed
Aisha Mohamed el 22 de En. de 2023
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 el 22 de En. de 2023
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 ?

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by