Conversation
|
@MaximSmolskiy, thank you for the patch! I think, generally this is the right direction to modify the function, and in this particular example it helps, but can it be improved even further in the same patch? Generally, when you have In particular, the last part of
which could be transformed to
here you greatly reduce magnitude of the two subtracted items and thus probably achieve higher accuracy. Probably the first part of Numeric methods are always very tricky, and probably here we need to spend a little more time in order to improve accuracy in most cases, not only in some cases. |
|
@vpisarev I grouped terms with same total degree |
|
Looks good to me in general. It'll be great to add a comment with the original formulae and the reason why the parts are grouped. |
|
Added brief comment |
Pull Request Readiness Checklist
Fix #27323
The problem that coefficients have quite big magnitudes and current calculations are subject to round-off error
Let
a1,a2,a3have quite big same magnitudes, then we see thatQcubedandR * Rhave same termsa1^6/729and-(a1^4 a2)/81(which will be reduced ind), but they level out the other terms (these terms have6th and5th degree and other terms - less or equal than4th degree).So, if these terms will participate in the calculation, this will lead to a huge round-off error.
But if we expand the expression, then round-off error should be less
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.