From Warwick Tucker's Validated Numerics

Percentage Accurate: 9.2% → 100.0%
Time: 767.0ms
Alternatives: 1
Speedup: 486.0×

Specification

?
\[\begin{array}{l} \\ \left(\left(333.75 \cdot {33096}^{6} + \left(77617 \cdot 77617\right) \cdot \left(\left(\left(\left(11 \cdot \left(77617 \cdot 77617\right)\right) \cdot \left(33096 \cdot 33096\right) + \left(-{33096}^{6}\right)\right) + -121 \cdot {33096}^{4}\right) + -2\right)\right) + 5.5 \cdot {33096}^{8}\right) + \frac{77617}{2 \cdot 33096} \end{array} \]
(FPCore ()
 :precision binary64
 (+
  (+
   (+
    (* 333.75 (pow 33096.0 6.0))
    (*
     (* 77617.0 77617.0)
     (+
      (+
       (+
        (* (* 11.0 (* 77617.0 77617.0)) (* 33096.0 33096.0))
        (- (pow 33096.0 6.0)))
       (* -121.0 (pow 33096.0 4.0)))
      -2.0)))
   (* 5.5 (pow 33096.0 8.0)))
  (/ 77617.0 (* 2.0 33096.0))))
double code() {
	return (((333.75 * pow(33096.0, 6.0)) + ((77617.0 * 77617.0) * (((((11.0 * (77617.0 * 77617.0)) * (33096.0 * 33096.0)) + -pow(33096.0, 6.0)) + (-121.0 * pow(33096.0, 4.0))) + -2.0))) + (5.5 * pow(33096.0, 8.0))) + (77617.0 / (2.0 * 33096.0));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code()
use fmin_fmax_functions
    code = (((333.75d0 * (33096.0d0 ** 6.0d0)) + ((77617.0d0 * 77617.0d0) * (((((11.0d0 * (77617.0d0 * 77617.0d0)) * (33096.0d0 * 33096.0d0)) + -(33096.0d0 ** 6.0d0)) + ((-121.0d0) * (33096.0d0 ** 4.0d0))) + (-2.0d0)))) + (5.5d0 * (33096.0d0 ** 8.0d0))) + (77617.0d0 / (2.0d0 * 33096.0d0))
end function
public static double code() {
	return (((333.75 * Math.pow(33096.0, 6.0)) + ((77617.0 * 77617.0) * (((((11.0 * (77617.0 * 77617.0)) * (33096.0 * 33096.0)) + -Math.pow(33096.0, 6.0)) + (-121.0 * Math.pow(33096.0, 4.0))) + -2.0))) + (5.5 * Math.pow(33096.0, 8.0))) + (77617.0 / (2.0 * 33096.0));
}
def code():
	return (((333.75 * math.pow(33096.0, 6.0)) + ((77617.0 * 77617.0) * (((((11.0 * (77617.0 * 77617.0)) * (33096.0 * 33096.0)) + -math.pow(33096.0, 6.0)) + (-121.0 * math.pow(33096.0, 4.0))) + -2.0))) + (5.5 * math.pow(33096.0, 8.0))) + (77617.0 / (2.0 * 33096.0))
function code()
	return Float64(Float64(Float64(Float64(333.75 * (33096.0 ^ 6.0)) + Float64(Float64(77617.0 * 77617.0) * Float64(Float64(Float64(Float64(Float64(11.0 * Float64(77617.0 * 77617.0)) * Float64(33096.0 * 33096.0)) + Float64(-(33096.0 ^ 6.0))) + Float64(-121.0 * (33096.0 ^ 4.0))) + -2.0))) + Float64(5.5 * (33096.0 ^ 8.0))) + Float64(77617.0 / Float64(2.0 * 33096.0)))
end
function tmp = code()
	tmp = (((333.75 * (33096.0 ^ 6.0)) + ((77617.0 * 77617.0) * (((((11.0 * (77617.0 * 77617.0)) * (33096.0 * 33096.0)) + -(33096.0 ^ 6.0)) + (-121.0 * (33096.0 ^ 4.0))) + -2.0))) + (5.5 * (33096.0 ^ 8.0))) + (77617.0 / (2.0 * 33096.0));
end
code[] := N[(N[(N[(N[(333.75 * N[Power[33096.0, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(77617.0 * 77617.0), $MachinePrecision] * N[(N[(N[(N[(N[(11.0 * N[(77617.0 * 77617.0), $MachinePrecision]), $MachinePrecision] * N[(33096.0 * 33096.0), $MachinePrecision]), $MachinePrecision] + (-N[Power[33096.0, 6.0], $MachinePrecision])), $MachinePrecision] + N[(-121.0 * N[Power[33096.0, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(5.5 * N[Power[33096.0, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(77617.0 / N[(2.0 * 33096.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(333.75 \cdot {33096}^{6} + \left(77617 \cdot 77617\right) \cdot \left(\left(\left(\left(11 \cdot \left(77617 \cdot 77617\right)\right) \cdot \left(33096 \cdot 33096\right) + \left(-{33096}^{6}\right)\right) + -121 \cdot {33096}^{4}\right) + -2\right)\right) + 5.5 \cdot {33096}^{8}\right) + \frac{77617}{2 \cdot 33096}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 1 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 9.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(333.75 \cdot {33096}^{6} + \left(77617 \cdot 77617\right) \cdot \left(\left(\left(\left(11 \cdot \left(77617 \cdot 77617\right)\right) \cdot \left(33096 \cdot 33096\right) + \left(-{33096}^{6}\right)\right) + -121 \cdot {33096}^{4}\right) + -2\right)\right) + 5.5 \cdot {33096}^{8}\right) + \frac{77617}{2 \cdot 33096} \end{array} \]
(FPCore ()
 :precision binary64
 (+
  (+
   (+
    (* 333.75 (pow 33096.0 6.0))
    (*
     (* 77617.0 77617.0)
     (+
      (+
       (+
        (* (* 11.0 (* 77617.0 77617.0)) (* 33096.0 33096.0))
        (- (pow 33096.0 6.0)))
       (* -121.0 (pow 33096.0 4.0)))
      -2.0)))
   (* 5.5 (pow 33096.0 8.0)))
  (/ 77617.0 (* 2.0 33096.0))))
double code() {
	return (((333.75 * pow(33096.0, 6.0)) + ((77617.0 * 77617.0) * (((((11.0 * (77617.0 * 77617.0)) * (33096.0 * 33096.0)) + -pow(33096.0, 6.0)) + (-121.0 * pow(33096.0, 4.0))) + -2.0))) + (5.5 * pow(33096.0, 8.0))) + (77617.0 / (2.0 * 33096.0));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code()
use fmin_fmax_functions
    code = (((333.75d0 * (33096.0d0 ** 6.0d0)) + ((77617.0d0 * 77617.0d0) * (((((11.0d0 * (77617.0d0 * 77617.0d0)) * (33096.0d0 * 33096.0d0)) + -(33096.0d0 ** 6.0d0)) + ((-121.0d0) * (33096.0d0 ** 4.0d0))) + (-2.0d0)))) + (5.5d0 * (33096.0d0 ** 8.0d0))) + (77617.0d0 / (2.0d0 * 33096.0d0))
end function
public static double code() {
	return (((333.75 * Math.pow(33096.0, 6.0)) + ((77617.0 * 77617.0) * (((((11.0 * (77617.0 * 77617.0)) * (33096.0 * 33096.0)) + -Math.pow(33096.0, 6.0)) + (-121.0 * Math.pow(33096.0, 4.0))) + -2.0))) + (5.5 * Math.pow(33096.0, 8.0))) + (77617.0 / (2.0 * 33096.0));
}
def code():
	return (((333.75 * math.pow(33096.0, 6.0)) + ((77617.0 * 77617.0) * (((((11.0 * (77617.0 * 77617.0)) * (33096.0 * 33096.0)) + -math.pow(33096.0, 6.0)) + (-121.0 * math.pow(33096.0, 4.0))) + -2.0))) + (5.5 * math.pow(33096.0, 8.0))) + (77617.0 / (2.0 * 33096.0))
function code()
	return Float64(Float64(Float64(Float64(333.75 * (33096.0 ^ 6.0)) + Float64(Float64(77617.0 * 77617.0) * Float64(Float64(Float64(Float64(Float64(11.0 * Float64(77617.0 * 77617.0)) * Float64(33096.0 * 33096.0)) + Float64(-(33096.0 ^ 6.0))) + Float64(-121.0 * (33096.0 ^ 4.0))) + -2.0))) + Float64(5.5 * (33096.0 ^ 8.0))) + Float64(77617.0 / Float64(2.0 * 33096.0)))
end
function tmp = code()
	tmp = (((333.75 * (33096.0 ^ 6.0)) + ((77617.0 * 77617.0) * (((((11.0 * (77617.0 * 77617.0)) * (33096.0 * 33096.0)) + -(33096.0 ^ 6.0)) + (-121.0 * (33096.0 ^ 4.0))) + -2.0))) + (5.5 * (33096.0 ^ 8.0))) + (77617.0 / (2.0 * 33096.0));
end
code[] := N[(N[(N[(N[(333.75 * N[Power[33096.0, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(77617.0 * 77617.0), $MachinePrecision] * N[(N[(N[(N[(N[(11.0 * N[(77617.0 * 77617.0), $MachinePrecision]), $MachinePrecision] * N[(33096.0 * 33096.0), $MachinePrecision]), $MachinePrecision] + (-N[Power[33096.0, 6.0], $MachinePrecision])), $MachinePrecision] + N[(-121.0 * N[Power[33096.0, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(5.5 * N[Power[33096.0, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(77617.0 / N[(2.0 * 33096.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(333.75 \cdot {33096}^{6} + \left(77617 \cdot 77617\right) \cdot \left(\left(\left(\left(11 \cdot \left(77617 \cdot 77617\right)\right) \cdot \left(33096 \cdot 33096\right) + \left(-{33096}^{6}\right)\right) + -121 \cdot {33096}^{4}\right) + -2\right)\right) + 5.5 \cdot {33096}^{8}\right) + \frac{77617}{2 \cdot 33096}
\end{array}

Alternative 1: 100.0% accurate, 486.0× speedup?

\[\begin{array}{l} \\ -0.8273960599468214 \end{array} \]
(FPCore () :precision binary64 -0.8273960599468214)
double code() {
	return -0.8273960599468214;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code()
use fmin_fmax_functions
    code = -0.8273960599468214d0
end function
public static double code() {
	return -0.8273960599468214;
}
def code():
	return -0.8273960599468214
function code()
	return -0.8273960599468214
end
function tmp = code()
	tmp = -0.8273960599468214;
end
code[] := -0.8273960599468214
\begin{array}{l}

\\
-0.8273960599468214
\end{array}
Derivation
  1. Initial program 9.2%

    \[\left(\left(333.75 \cdot {33096}^{6} + \left(77617 \cdot 77617\right) \cdot \left(\left(\left(\left(11 \cdot \left(77617 \cdot 77617\right)\right) \cdot \left(33096 \cdot 33096\right) + \left(-{33096}^{6}\right)\right) + -121 \cdot {33096}^{4}\right) + -2\right)\right) + 5.5 \cdot {33096}^{8}\right) + \frac{77617}{2 \cdot 33096} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(\left(\frac{1335}{4} \cdot {33096}^{6} + \left(77617 \cdot 77617\right) \cdot \left(\left(\left(\left(11 \cdot \left(77617 \cdot 77617\right)\right) \cdot \left(33096 \cdot 33096\right) + \left(-{33096}^{6}\right)\right) + -121 \cdot {33096}^{4}\right) + -2\right)\right) + \frac{11}{2} \cdot {33096}^{8}\right) + \frac{77617}{2 \cdot 33096}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{-0.8273960599468214} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2025100 
(FPCore ()
  :name "From Warwick Tucker's Validated Numerics"
  :precision binary64
  (+ (+ (+ (* 333.75 (pow 33096.0 6.0)) (* (* 77617.0 77617.0) (+ (+ (+ (* (* 11.0 (* 77617.0 77617.0)) (* 33096.0 33096.0)) (- (pow 33096.0 6.0))) (* -121.0 (pow 33096.0 4.0))) -2.0))) (* 5.5 (pow 33096.0 8.0))) (/ 77617.0 (* 2.0 33096.0))))