Skip to content

cbrtf64.rs streamlining opportunity ? #1276

Description

@mogando668

At line 90 of cbrtf64.rs

t = t * ((P0 + r * (P1 + r * P2)) + ((r * r) * r) * (P3 + r * P4));

I've noticed the expression has 7 mults and 4 adds. Perhaps there are performance rationale for duplications to powers of r that I'm unaware of, but I was wondering would following the Horner's polynomial method work just as well, now with only 5 mults ?

t *= r * (r * (r * (r * (P4) + P3) + P2) + P1) + P0 ;

It also improves readability by placing all copies of r on the left side, and all the co-efficients on the right, in big-endian order. Pairs of parentheses has shrunk from 6 to 4 (possibly 3, since grouping (P4) is superfluous).

my 2 cents

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions