Skip to content

solveCubic if a0 is too small(like 10^-13), the solution is abnormal. #27323

@chinwuDebug

Description

@chinwuDebug

System Information

python code,Version:opencv-python 4.11.0.86
System: windows 11

Detailed description

If you use the cv.solveCubic function to solve a cubic equation, if the coefficient of cubic is very small, 10 ^-13, the solution is abnormal.

Steps to reproduce

example:

import cv2
import numpy as np


def solve_polynomial(a, b, c, d):
    roots = np.zeros(3, dtype=np.float64)
    cv2.solveCubic(np.array([a, b, c, d], dtype=np.float64), roots)
    return roots.tolist()


# example:
a = 2 * 10 ** (-13)
b = 1
c = -2
d = 1
roots = solve_polynomial(a, b, c, d)
print("root:", roots)

output:

root: [-5000000000002.0, 14339.64892578125, -14337.646728515625]

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions