Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

`paddle.divide` Incorrectly Computes Complex Divided by Infinity.

Open rookieLiu2018 opened this issue 5 months ago • 1 comments
trafficstars

bug描述 Describe the Bug

When dividing a complex number by positive infinity using paddle.divide, the result is (nan+nanj). This is mathematically incorrect. The expected result is (0+0j). The equivalent operation in NumPy produces the correct result, 0j.

import paddle
import numpy as np
print(paddle.__version__)
paddle.set_device('cpu')
x0 = paddle.to_tensor(1.0, dtype='complex128')
x1 = paddle.to_tensor(float('inf'), dtype='float64')
y = paddle.divide(x0, x1)  
print(y)
x0_np = np.array(1.0, dtype=np.complex128)
x1_np = np.array(float('inf'), dtype=np.float64)
y_np = np.divide(x0_np, x1_np)
print(y_np)
output:
3.0.0
Tensor(shape=[], dtype=complex128, place=Place(cpu), stop_gradient=True,
       (nan+nanj))
0j

其他补充信息 Additional Supplementary Information

No response

rookieLiu2018 avatar Jun 10 '25 03:06 rookieLiu2018

你好,这个问题我们已经记录并且近期会进行修复,感谢你的反馈

HydrogenSulfate avatar Jun 13 '25 06:06 HydrogenSulfate

closed as #73331 has been merged

HydrogenSulfate avatar Jun 28 '25 08:06 HydrogenSulfate