fma_test2

Percentage Accurate: 33.8% → 99.6%
Time: 2.2s
Alternatives: 4
Speedup: 1.6×

Specification

?
\[1.9 \leq t \land t \leq 2.1\]
\[1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308} \]
(FPCore (t)
  :precision binary64
  (- (* 1.7e+308 t) 1.7e+308))
double code(double t) {
	return (1.7e+308 * t) - 1.7e+308;
}
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(t)
use fmin_fmax_functions
    real(8), intent (in) :: t
    code = (1.7d+308 * t) - 1.7d+308
end function
public static double code(double t) {
	return (1.7e+308 * t) - 1.7e+308;
}
def code(t):
	return (1.7e+308 * t) - 1.7e+308
function code(t)
	return Float64(Float64(1.7e+308 * t) - 1.7e+308)
end
function tmp = code(t)
	tmp = (1.7e+308 * t) - 1.7e+308;
end
code[t_] := N[(N[(1.7e+308 * t), $MachinePrecision] - 1.7e+308), $MachinePrecision]
1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308}

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 4 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: 33.8% accurate, 1.0× speedup?

\[1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308} \]
(FPCore (t)
  :precision binary64
  (- (* 1.7e+308 t) 1.7e+308))
double code(double t) {
	return (1.7e+308 * t) - 1.7e+308;
}
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(t)
use fmin_fmax_functions
    real(8), intent (in) :: t
    code = (1.7d+308 * t) - 1.7d+308
end function
public static double code(double t) {
	return (1.7e+308 * t) - 1.7e+308;
}
def code(t):
	return (1.7e+308 * t) - 1.7e+308
function code(t)
	return Float64(Float64(1.7e+308 * t) - 1.7e+308)
end
function tmp = code(t)
	tmp = (1.7e+308 * t) - 1.7e+308;
end
code[t_] := N[(N[(1.7e+308 * t), $MachinePrecision] - 1.7e+308), $MachinePrecision]
1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308}

Alternative 1: 99.6% accurate, 0.6× speedup?

\[\left(1.7 \cdot 10^{+308} - \frac{1.7 \cdot 10^{+308}}{t}\right) \cdot t \]
(FPCore (t)
  :precision binary64
  (* (- 1.7e+308 (/ 1.7e+308 t)) t))
double code(double t) {
	return (1.7e+308 - (1.7e+308 / t)) * t;
}
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(t)
use fmin_fmax_functions
    real(8), intent (in) :: t
    code = (1.7d+308 - (1.7d+308 / t)) * t
end function
public static double code(double t) {
	return (1.7e+308 - (1.7e+308 / t)) * t;
}
def code(t):
	return (1.7e+308 - (1.7e+308 / t)) * t
function code(t)
	return Float64(Float64(1.7e+308 - Float64(1.7e+308 / t)) * t)
end
function tmp = code(t)
	tmp = (1.7e+308 - (1.7e+308 / t)) * t;
end
code[t_] := N[(N[(1.7e+308 - N[(1.7e+308 / t), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\left(1.7 \cdot 10^{+308} - \frac{1.7 \cdot 10^{+308}}{t}\right) \cdot t
Derivation
  1. Initial program 33.8%

    \[1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308} \]
  2. Taylor expanded in t around inf

    \[\leadsto \color{blue}{t \cdot \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto t \cdot \color{blue}{\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}\right)} \]
    2. lower--.f64N/A

      \[\leadsto t \cdot \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - \color{blue}{170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}}\right) \]
    3. lower-*.f64N/A

      \[\leadsto t \cdot \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \color{blue}{\frac{1}{t}}\right) \]
    4. lower-/.f6499.3%

      \[\leadsto t \cdot \left(1.7 \cdot 10^{+308} - 1.7 \cdot 10^{+308} \cdot \frac{1}{\color{blue}{t}}\right) \]
  4. Applied rewrites99.3%

    \[\leadsto \color{blue}{t \cdot \left(1.7 \cdot 10^{+308} - 1.7 \cdot 10^{+308} \cdot \frac{1}{t}\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto t \cdot \color{blue}{\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}\right) \cdot \color{blue}{t} \]
    3. lower-*.f6499.3%

      \[\leadsto \left(1.7 \cdot 10^{+308} - 1.7 \cdot 10^{+308} \cdot \frac{1}{t}\right) \cdot \color{blue}{t} \]
    4. lift-*.f64N/A

      \[\leadsto \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}\right) \cdot t \]
    5. lift-/.f64N/A

      \[\leadsto \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}\right) \cdot t \]
    6. mult-flip-revN/A

      \[\leadsto \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - \frac{170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}{t}\right) \cdot t \]
    7. lower-/.f6499.5%

      \[\leadsto \left(1.7 \cdot 10^{+308} - \frac{1.7 \cdot 10^{+308}}{t}\right) \cdot t \]
  6. Applied rewrites99.5%

    \[\leadsto \left(1.7 \cdot 10^{+308} - \frac{1.7 \cdot 10^{+308}}{t}\right) \cdot \color{blue}{t} \]
  7. Add Preprocessing

Alternative 2: 99.5% accurate, 1.1× speedup?

\[\mathsf{fma}\left(t, 1.7 \cdot 10^{+308}, -1.7 \cdot 10^{+308}\right) \]
(FPCore (t)
  :precision binary64
  (fma t 1.7e+308 -1.7e+308))
double code(double t) {
	return fma(t, 1.7e+308, -1.7e+308);
}
function code(t)
	return fma(t, 1.7e+308, -1.7e+308)
end
code[t_] := N[(t * 1.7e+308 + -1.7e+308), $MachinePrecision]
\mathsf{fma}\left(t, 1.7 \cdot 10^{+308}, -1.7 \cdot 10^{+308}\right)
Derivation
  1. Initial program 33.8%

    \[1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308} \]
  2. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot t - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000} \]
    2. sub-negate-revN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot t\right)\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - \color{blue}{170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot t}\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{neg}\left(\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - \color{blue}{t \cdot 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}\right)\right) \]
    5. fp-cancel-sub-sign-invN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + \left(\mathsf{neg}\left(t\right)\right) \cdot 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)}\right) \]
    6. distribute-rgt1-inN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(t\right)\right) + 1\right) \cdot 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}\right) \]
    7. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(t\right)\right) + 1\right) \cdot \left(\mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right)} \]
    8. distribute-lft1-inN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t\right)\right) \cdot \left(\mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right) + \left(\mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right)} \]
    9. distribute-lft-neg-outN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t \cdot \left(\mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right)\right)\right)} + \left(\mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right) \]
    10. distribute-rgt-neg-outN/A

      \[\leadsto \color{blue}{t \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right)\right)\right)} + \left(\mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right) \]
    11. remove-double-negN/A

      \[\leadsto t \cdot \color{blue}{170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000} + \left(\mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right) \]
    12. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, \mathsf{neg}\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\right)\right)} \]
    13. metadata-eval99.6%

      \[\leadsto \mathsf{fma}\left(t, 1.7 \cdot 10^{+308}, \color{blue}{-1.7 \cdot 10^{+308}}\right) \]
  3. Applied rewrites99.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(t, 1.7 \cdot 10^{+308}, -1.7 \cdot 10^{+308}\right)} \]
  4. Add Preprocessing

Alternative 3: 33.8% accurate, 1.6× speedup?

\[t \cdot 1.7 \cdot 10^{+308} \]
(FPCore (t)
  :precision binary64
  (* t 1.7e+308))
double code(double t) {
	return t * 1.7e+308;
}
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(t)
use fmin_fmax_functions
    real(8), intent (in) :: t
    code = t * 1.7d+308
end function
public static double code(double t) {
	return t * 1.7e+308;
}
def code(t):
	return t * 1.7e+308
function code(t)
	return Float64(t * 1.7e+308)
end
function tmp = code(t)
	tmp = t * 1.7e+308;
end
code[t_] := N[(t * 1.7e+308), $MachinePrecision]
t \cdot 1.7 \cdot 10^{+308}
Derivation
  1. Initial program 33.8%

    \[1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308} \]
  2. Taylor expanded in t around inf

    \[\leadsto \color{blue}{t \cdot \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto t \cdot \color{blue}{\left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}\right)} \]
    2. lower--.f64N/A

      \[\leadsto t \cdot \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - \color{blue}{170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \frac{1}{t}}\right) \]
    3. lower-*.f64N/A

      \[\leadsto t \cdot \left(170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \cdot \color{blue}{\frac{1}{t}}\right) \]
    4. lower-/.f6499.3%

      \[\leadsto t \cdot \left(1.7 \cdot 10^{+308} - 1.7 \cdot 10^{+308} \cdot \frac{1}{\color{blue}{t}}\right) \]
  4. Applied rewrites99.3%

    \[\leadsto \color{blue}{t \cdot \left(1.7 \cdot 10^{+308} - 1.7 \cdot 10^{+308} \cdot \frac{1}{t}\right)} \]
  5. Taylor expanded in t around inf

    \[\leadsto t \cdot 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \]
  6. Step-by-step derivation
    1. Applied rewrites33.8%

      \[\leadsto t \cdot 1.7 \cdot 10^{+308} \]
    2. Add Preprocessing

    Alternative 4: 0.0% accurate, 6.6× speedup?

    \[-1.7 \cdot 10^{+308} \]
    (FPCore (t)
      :precision binary64
      -1.7e+308)
    double code(double t) {
    	return -1.7e+308;
    }
    
    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(t)
    use fmin_fmax_functions
        real(8), intent (in) :: t
        code = -1.7d+308
    end function
    
    public static double code(double t) {
    	return -1.7e+308;
    }
    
    def code(t):
    	return -1.7e+308
    
    function code(t)
    	return -1.7e+308
    end
    
    function tmp = code(t)
    	tmp = -1.7e+308;
    end
    
    code[t_] := -1.7e+308
    
    -1.7 \cdot 10^{+308}
    
    Derivation
    1. Initial program 33.8%

      \[1.7 \cdot 10^{+308} \cdot t - 1.7 \cdot 10^{+308} \]
    2. Taylor expanded in t around 0

      \[\leadsto \color{blue}{-170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000} \]
    3. Step-by-step derivation
      1. Applied rewrites0.0%

        \[\leadsto \color{blue}{-1.7 \cdot 10^{+308}} \]
      2. Add Preprocessing

      Developer Target 1: 99.6% accurate, 0.9× speedup?

      \[\mathsf{fma}\left(1.7 \cdot 10^{+308}, t, -1.7 \cdot 10^{+308}\right) \]
      (FPCore (t)
        :precision binary64
        (fma 1.7e+308 t (- 1.7e+308)))
      double code(double t) {
      	return fma(1.7e+308, t, -1.7e+308);
      }
      
      function code(t)
      	return fma(1.7e+308, t, Float64(-1.7e+308))
      end
      
      code[t_] := N[(1.7e+308 * t + (-1.7e+308)), $MachinePrecision]
      
      \mathsf{fma}\left(1.7 \cdot 10^{+308}, t, -1.7 \cdot 10^{+308}\right)
      

      Reproduce

      ?
      herbie shell --seed 2025233 
      (FPCore (t)
        :name "fma_test2"
        :precision binary64
        :pre (and (<= 1.9 t) (<= t 2.1))
      
        :alt
        (! :herbie-platform c (let ((x 170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)) (fma x t (- x))))
      
        (- (* 1.7e+308 t) 1.7e+308))