Borrar filtros
Borrar filtros

Simplify symbolic division abs(Z)/Z

1 visualización (últimos 30 días)
Luciano Boglione
Luciano Boglione el 2 de Nov. de 2023
Respondida: Walter Roberson el 3 de Nov. de 2023
In a symbolic expression with syms Z complex, Matlab does not simplify simplify(abs(Z)^2/Z) to conj(Z) but it simplifies simplify(abs(Z)^2/conj(Z)) to Z. Is it possible to make sure that simplify(abs(Z)^2/Z) yields conj(Z)? I'm working with R2023b. Thanks!

Respuestas (2)

Torsten
Torsten el 2 de Nov. de 2023
Editada: Torsten el 2 de Nov. de 2023
Use z*z' instead of abs(z)^2:
syms z
u = z*z'/z
u = 
  2 comentarios
Luciano Boglione
Luciano Boglione el 2 de Nov. de 2023
Thank you for your suggestion. However, I get abs(Z)^2/Z as a result of a calculation on complex symbolic varialbles - then, I try simplify( expression that contains abs(Z)^2/Z ) but it doesn't simplify it. That's my issue!
Torsten
Torsten el 3 de Nov. de 2023
Editada: Torsten el 3 de Nov. de 2023
Then I think you are out of luck. Why do you want to simplify ? Just for optical reasons ?
This will work, but it's the sledge hammer:
syms z
u = abs(z)^2/z;
u = subs(u,abs(z)^2,z'*z)
u = 

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 3 de Nov. de 2023
syms z
syms zr zi real
u = abs(z)^2/z
u = 
us = simplify(subs(u, z, zr + 1i*zi))
us = 
After which you would need to substitute conj(z) for zr-zi*1i
However it is probably easiest to do something like
syms z
u = abs(z)^2/z + 5*z^2 - 3*z + 2
u = 
subs(u, abs(z)^2/z, conj(z))
ans = 
If you have something more complex, where you have the general pattern abs(EXPRESSION)^2/EXPRESSION then you could proceed by using mapSymType ... but it does get complicated if you have terms such as (x*abs(x + y)^2)/(y*(x + y)) then it can be complicated to properly detect a match.

Community Treasure Hunt

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

Start Hunting!

Translated by