newsynth-0.4.0.0: Exact and approximate synthesis of quantum circuits

Safe HaskellNone
LanguageHaskell98

Quantum.Synthesis.QuadraticEquation

Description

This module provides a type class Quadratic, for solving quadratic equations.

Synopsis

Documentation

class Quadratic t a where Source #

This type class provides a primitive method for solving quadratic equations. For many floating-point or fixed-precision representations of real numbers, using the usual "quadratic formula" results in a significant loss of precision. Instances of the Quadratic class should provide an efficient high-precision method when possible.

Minimal complete definition

quadratic

Methods

quadratic :: t -> t -> t -> Maybe (a, a) Source #

quadratic a b c: solve the quadratic equation ax² + bx + c = 0. Return the pair of solutions (x₁, x₂) with x₁ ≤ x₂, or Nothing if no solution exists. Note that the coefficients a, b, and c can be taken to be of an exact type; therefore instances have the opportunity to work with infinite precision.

Instances

ToReal t => Quadratic t Double Source # 

Methods

quadratic :: t -> t -> t -> Maybe (Double, Double) Source #

(Fractional t, Floor t, Ord t, Precision e) => Quadratic t (FixedPrec e) Source # 

Methods

quadratic :: t -> t -> t -> Maybe (FixedPrec e, FixedPrec e) Source #