Why is airy(3,1) complex? (No numerical round-off in the complex part)

1 回表示 (過去 30 日間)
David Wilson
David Wilson 2012 年 9 月 18 日
Why does Matlab return a complex number for airy(3,1)?
The result is a pure real, the imaginary part is identically zero (no numerical round off), yet the value is considered complex?
>> format long
>> y = airy(3,1)
y =
0.932435933392775
>> isreal(y)
ans =
0
>> format hex
>> imag(y)
ans =
0000000000000000

回答 (3 件)

Wayne King
Wayne King 2012 年 9 月 18 日
編集済み: Wayne King 2012 年 9 月 18 日
What release are you using?
>> format long
>> isreal(airy(3,1))
ans =
1

David Wilson
David Wilson 2012 年 9 月 18 日
R2012a
  2 件のコメント
Wayne King
Wayne King 2012 年 9 月 18 日
I've confirmed that behavior in R2012a, but it is fixed in R2012b, let me check the bug reports
Wayne King
Wayne King 2012 年 9 月 18 日
I don't see it as a bug report David, but the behavior is fixed in 12b, airy(3,1) returns the scalar with attribute real

サインインしてコメントする。


Matt Tearle
Matt Tearle 2012 年 9 月 18 日
Looks like a bug in 12a. If you do
whos y
it shows the class as double (complex), so isreal is working properly, but how the heck it gets a complex y with 0 real part is a mystery to me. It looks like the problem is actually coming from besselmx, which airy calls:
z = besselmx(real('B'),1,1)
whos z
It's fixed in 12b, where airy is now a built-in.

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by