Skip to content

Potential improvements for System.Numerics.Complex #104233

@lilinus

Description

@lilinus

I have found a number of potential places for improvements in System.Numerics.Complex:

  1. Use Math.SinCos when available in various places.
  2. Use double.Hypot when available in Complex.Hypot
  3. sinh and cosh are calculated simultaneously as:
double p = Math.Exp(x);
double q = 1 / p;
double sinh = (p - q) * 0.5;
double cosh = (p + q) * 0.5;

This is inaccurate for sinh due to catastrophic cancellation of p-q when x is close to zero.
Could perhaps be solved by using Math.Sinh and Math.Cosh within a threshold?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions