채택된 답변

Walter Roberson
Walter Roberson 2020년 10월 14일

2 개 추천

>> a=complex(rand,rand)
a =
0.0975404049994095 + 0.278498218867048i
>> b=complex(rand,rand)
b =
0.546881519204984 + 0.957506835434298i
>> abs(a-b)^2
ans =
0.662960138288077
>> a^2-2*a*b+b^2
ans =
-0.259145264457063 + 0.610212976647027i

댓글 수: 2

Niklas Kurz
Niklas Kurz 2020년 10월 18일
편집: Niklas Kurz 2020년 10월 18일
Hence it's incorrect for complex numbers. Alrigth. But for real numbers it should work. However
expand(abs(real(a)-real(b))^2
still doesn't expand.
expand(simplify(abs(real(a) -real(b) ) ^2))

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

태그

질문:

2020년 10월 14일

편집:

2020년 10월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by