(log (- (exp (/ (- z0) z1)) -1))

Percentage Accurate: 99.3% → 99.3%
Time: 3.9s
Alternatives: 5
Speedup: 1.0×

Specification

?
\[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
(FPCore (z0 z1)
  :precision binary64
  (log (- (exp (/ (- z0) z1)) -1.0)))
double code(double z0, double z1) {
	return log((exp((-z0 / z1)) - -1.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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    code = log((exp((-z0 / z1)) - (-1.0d0)))
end function
public static double code(double z0, double z1) {
	return Math.log((Math.exp((-z0 / z1)) - -1.0));
}
def code(z0, z1):
	return math.log((math.exp((-z0 / z1)) - -1.0))
function code(z0, z1)
	return log(Float64(exp(Float64(Float64(-z0) / z1)) - -1.0))
end
function tmp = code(z0, z1)
	tmp = log((exp((-z0 / z1)) - -1.0));
end
code[z0_, z1_] := N[Log[N[(N[Exp[N[((-z0) / z1), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision]
\log \left(e^{\frac{-z0}{z1}} - -1\right)

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

\[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
(FPCore (z0 z1)
  :precision binary64
  (log (- (exp (/ (- z0) z1)) -1.0)))
double code(double z0, double z1) {
	return log((exp((-z0 / z1)) - -1.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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    code = log((exp((-z0 / z1)) - (-1.0d0)))
end function
public static double code(double z0, double z1) {
	return Math.log((Math.exp((-z0 / z1)) - -1.0));
}
def code(z0, z1):
	return math.log((math.exp((-z0 / z1)) - -1.0))
function code(z0, z1)
	return log(Float64(exp(Float64(Float64(-z0) / z1)) - -1.0))
end
function tmp = code(z0, z1)
	tmp = log((exp((-z0 / z1)) - -1.0));
end
code[z0_, z1_] := N[Log[N[(N[Exp[N[((-z0) / z1), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision]
\log \left(e^{\frac{-z0}{z1}} - -1\right)

Alternative 1: 69.9% accurate, 1.2× speedup?

\[\begin{array}{l} t_0 := \frac{-z0}{z1}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+57}:\\ \;\;\;\;z0 \cdot \frac{0.6931471805599453 \cdot z1 - 0.5 \cdot z0}{z0 \cdot z1}\\ \mathbf{elif}\;t\_0 \leq -1000000000000:\\ \;\;\;\;\frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - \left(0.5 \cdot z0\right) \cdot z1}{z1}}{z1}\\ \mathbf{else}:\\ \;\;\;\;0.6931471805599453 + -0.5 \cdot \frac{z0}{z1}\\ \end{array} \]
(FPCore (z0 z1)
  :precision binary64
  (let* ((t_0 (/ (- z0) z1)))
  (if (<= t_0 -1e+57)
    (* z0 (/ (- (* 0.6931471805599453 z1) (* 0.5 z0)) (* z0 z1)))
    (if (<= t_0 -1000000000000.0)
      (/ (/ (- (* (* (log 2.0) z1) z1) (* (* 0.5 z0) z1)) z1) z1)
      (+ 0.6931471805599453 (* -0.5 (/ z0 z1)))))))
double code(double z0, double z1) {
	double t_0 = -z0 / z1;
	double tmp;
	if (t_0 <= -1e+57) {
		tmp = z0 * (((0.6931471805599453 * z1) - (0.5 * z0)) / (z0 * z1));
	} else if (t_0 <= -1000000000000.0) {
		tmp = ((((log(2.0) * z1) * z1) - ((0.5 * z0) * z1)) / z1) / z1;
	} else {
		tmp = 0.6931471805599453 + (-0.5 * (z0 / z1));
	}
	return tmp;
}
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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -z0 / z1
    if (t_0 <= (-1d+57)) then
        tmp = z0 * (((0.6931471805599453d0 * z1) - (0.5d0 * z0)) / (z0 * z1))
    else if (t_0 <= (-1000000000000.0d0)) then
        tmp = ((((log(2.0d0) * z1) * z1) - ((0.5d0 * z0) * z1)) / z1) / z1
    else
        tmp = 0.6931471805599453d0 + ((-0.5d0) * (z0 / z1))
    end if
    code = tmp
end function
public static double code(double z0, double z1) {
	double t_0 = -z0 / z1;
	double tmp;
	if (t_0 <= -1e+57) {
		tmp = z0 * (((0.6931471805599453 * z1) - (0.5 * z0)) / (z0 * z1));
	} else if (t_0 <= -1000000000000.0) {
		tmp = ((((Math.log(2.0) * z1) * z1) - ((0.5 * z0) * z1)) / z1) / z1;
	} else {
		tmp = 0.6931471805599453 + (-0.5 * (z0 / z1));
	}
	return tmp;
}
def code(z0, z1):
	t_0 = -z0 / z1
	tmp = 0
	if t_0 <= -1e+57:
		tmp = z0 * (((0.6931471805599453 * z1) - (0.5 * z0)) / (z0 * z1))
	elif t_0 <= -1000000000000.0:
		tmp = ((((math.log(2.0) * z1) * z1) - ((0.5 * z0) * z1)) / z1) / z1
	else:
		tmp = 0.6931471805599453 + (-0.5 * (z0 / z1))
	return tmp
function code(z0, z1)
	t_0 = Float64(Float64(-z0) / z1)
	tmp = 0.0
	if (t_0 <= -1e+57)
		tmp = Float64(z0 * Float64(Float64(Float64(0.6931471805599453 * z1) - Float64(0.5 * z0)) / Float64(z0 * z1)));
	elseif (t_0 <= -1000000000000.0)
		tmp = Float64(Float64(Float64(Float64(Float64(log(2.0) * z1) * z1) - Float64(Float64(0.5 * z0) * z1)) / z1) / z1);
	else
		tmp = Float64(0.6931471805599453 + Float64(-0.5 * Float64(z0 / z1)));
	end
	return tmp
end
function tmp_2 = code(z0, z1)
	t_0 = -z0 / z1;
	tmp = 0.0;
	if (t_0 <= -1e+57)
		tmp = z0 * (((0.6931471805599453 * z1) - (0.5 * z0)) / (z0 * z1));
	elseif (t_0 <= -1000000000000.0)
		tmp = ((((log(2.0) * z1) * z1) - ((0.5 * z0) * z1)) / z1) / z1;
	else
		tmp = 0.6931471805599453 + (-0.5 * (z0 / z1));
	end
	tmp_2 = tmp;
end
code[z0_, z1_] := Block[{t$95$0 = N[((-z0) / z1), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+57], N[(z0 * N[(N[(N[(0.6931471805599453 * z1), $MachinePrecision] - N[(0.5 * z0), $MachinePrecision]), $MachinePrecision] / N[(z0 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1000000000000.0], N[(N[(N[(N[(N[(N[Log[2.0], $MachinePrecision] * z1), $MachinePrecision] * z1), $MachinePrecision] - N[(N[(0.5 * z0), $MachinePrecision] * z1), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision] / z1), $MachinePrecision], N[(0.6931471805599453 + N[(-0.5 * N[(z0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{-z0}{z1}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+57}:\\
\;\;\;\;z0 \cdot \frac{0.6931471805599453 \cdot z1 - 0.5 \cdot z0}{z0 \cdot z1}\\

\mathbf{elif}\;t\_0 \leq -1000000000000:\\
\;\;\;\;\frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - \left(0.5 \cdot z0\right) \cdot z1}{z1}}{z1}\\

\mathbf{else}:\\
\;\;\;\;0.6931471805599453 + -0.5 \cdot \frac{z0}{z1}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (neg.f64 z0) z1) < -1e57

    1. Initial program 99.3%

      \[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
    2. Taylor expanded in z0 around 0

      \[\leadsto \color{blue}{\log 2 + \frac{-1}{2} \cdot \frac{z0}{z1}} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2} \cdot \frac{z0}{z1}} \]
      2. lower-log.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2}} \cdot \frac{z0}{z1} \]
      3. lower-*.f64N/A

        \[\leadsto \log 2 + \frac{-1}{2} \cdot \color{blue}{\frac{z0}{z1}} \]
      4. lower-/.f6466.4%

        \[\leadsto \log 2 + -0.5 \cdot \frac{z0}{\color{blue}{z1}} \]
    4. Applied rewrites66.4%

      \[\leadsto \color{blue}{\log 2 + -0.5 \cdot \frac{z0}{z1}} \]
    5. Taylor expanded in z0 around inf

      \[\leadsto z0 \cdot \color{blue}{\left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \frac{1}{z1}\right)} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \color{blue}{\frac{1}{z1}}\right) \]
      3. lower-/.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \frac{\color{blue}{1}}{z1}\right) \]
      4. lower-log.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \frac{1}{z1}\right) \]
      5. lower-*.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \frac{1}{\color{blue}{z1}}\right) \]
      6. lower-/.f6466.3%

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - 0.5 \cdot \frac{1}{z1}\right) \]
    7. Applied rewrites66.3%

      \[\leadsto z0 \cdot \color{blue}{\left(\frac{\log 2}{z0} - 0.5 \cdot \frac{1}{z1}\right)} \]
    8. Evaluated real constant66.3%

      \[\leadsto z0 \cdot \left(\frac{0.6931471805599453}{z0} - 0.5 \cdot \frac{1}{z1}\right) \]
    9. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} - \frac{1}{2} \cdot \color{blue}{\frac{1}{z1}}\right) \]
      2. lift-*.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} - \frac{1}{2} \cdot \frac{1}{\color{blue}{z1}}\right) \]
      3. fp-cancel-sub-sign-invN/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \color{blue}{\frac{1}{z1}}\right) \]
      4. lift-/.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \frac{\color{blue}{1}}{z1}\right) \]
      5. metadata-evalN/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \frac{-1}{2} \cdot \frac{1}{z1}\right) \]
      6. lift-/.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \frac{-1}{2} \cdot \frac{1}{z1}\right) \]
      7. mult-flipN/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \frac{\frac{-1}{2}}{z1}\right) \]
      8. common-denominatorN/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 + \frac{-1}{2} \cdot z0}{z0 \cdot \color{blue}{z1}} \]
      9. lower-/.f64N/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 + \frac{-1}{2} \cdot z0}{z0 \cdot \color{blue}{z1}} \]
      10. fp-cancel-sign-sub-invN/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot z0}{z0 \cdot z1} \]
      11. metadata-evalN/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \frac{1}{2} \cdot z0}{z0 \cdot z1} \]
      12. lower--.f64N/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \frac{1}{2} \cdot z0}{z0 \cdot z1} \]
      13. lower-*.f64N/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \frac{1}{2} \cdot z0}{z0 \cdot z1} \]
      14. lower-*.f64N/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \frac{1}{2} \cdot z0}{z0 \cdot z1} \]
      15. lower-*.f6455.3%

        \[\leadsto z0 \cdot \frac{0.6931471805599453 \cdot z1 - 0.5 \cdot z0}{z0 \cdot z1} \]
    10. Applied rewrites55.3%

      \[\leadsto z0 \cdot \frac{0.6931471805599453 \cdot z1 - 0.5 \cdot z0}{z0 \cdot \color{blue}{z1}} \]

    if -1e57 < (/.f64 (neg.f64 z0) z1) < -1e12

    1. Initial program 99.3%

      \[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
    2. Taylor expanded in z0 around 0

      \[\leadsto \color{blue}{\log 2 + \frac{-1}{2} \cdot \frac{z0}{z1}} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2} \cdot \frac{z0}{z1}} \]
      2. lower-log.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2}} \cdot \frac{z0}{z1} \]
      3. lower-*.f64N/A

        \[\leadsto \log 2 + \frac{-1}{2} \cdot \color{blue}{\frac{z0}{z1}} \]
      4. lower-/.f6466.4%

        \[\leadsto \log 2 + -0.5 \cdot \frac{z0}{\color{blue}{z1}} \]
    4. Applied rewrites66.4%

      \[\leadsto \color{blue}{\log 2 + -0.5 \cdot \frac{z0}{z1}} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2} \cdot \frac{z0}{z1}} \]
      2. lift-*.f64N/A

        \[\leadsto \log 2 + \frac{-1}{2} \cdot \color{blue}{\frac{z0}{z1}} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \log 2 - \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot \frac{z0}{z1}} \]
      4. lift-/.f64N/A

        \[\leadsto \log 2 - \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot \frac{z0}{\color{blue}{z1}} \]
      5. associate-*r/N/A

        \[\leadsto \log 2 - \frac{\left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot z0}{\color{blue}{z1}} \]
      6. sub-to-fractionN/A

        \[\leadsto \frac{\log 2 \cdot z1 - \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot z0}{\color{blue}{z1}} \]
      7. lower-/.f64N/A

        \[\leadsto \frac{\log 2 \cdot z1 - \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot z0}{\color{blue}{z1}} \]
      8. lower--.f64N/A

        \[\leadsto \frac{\log 2 \cdot z1 - \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot z0}{z1} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\log 2 \cdot z1 - \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot z0}{z1} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\log 2 \cdot z1 - \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot z0}{z1} \]
      11. metadata-eval66.3%

        \[\leadsto \frac{\log 2 \cdot z1 - 0.5 \cdot z0}{z1} \]
    6. Applied rewrites66.3%

      \[\leadsto \frac{\log 2 \cdot z1 - 0.5 \cdot z0}{\color{blue}{z1}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\log 2 \cdot z1 - \frac{1}{2} \cdot z0}{\color{blue}{z1}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\log 2 \cdot z1 - \frac{1}{2} \cdot z0}{z1} \]
      3. div-subN/A

        \[\leadsto \frac{\log 2 \cdot z1}{z1} - \color{blue}{\frac{\frac{1}{2} \cdot z0}{z1}} \]
      4. frac-subN/A

        \[\leadsto \frac{\left(\log 2 \cdot z1\right) \cdot z1 - z1 \cdot \left(\frac{1}{2} \cdot z0\right)}{\color{blue}{z1 \cdot z1}} \]
      5. associate-/r*N/A

        \[\leadsto \frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - z1 \cdot \left(\frac{1}{2} \cdot z0\right)}{z1}}{\color{blue}{z1}} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - z1 \cdot \left(\frac{1}{2} \cdot z0\right)}{z1}}{\color{blue}{z1}} \]
      7. lower-/.f64N/A

        \[\leadsto \frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - z1 \cdot \left(\frac{1}{2} \cdot z0\right)}{z1}}{z1} \]
      8. lower--.f64N/A

        \[\leadsto \frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - z1 \cdot \left(\frac{1}{2} \cdot z0\right)}{z1}}{z1} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - z1 \cdot \left(\frac{1}{2} \cdot z0\right)}{z1}}{z1} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - \left(\frac{1}{2} \cdot z0\right) \cdot z1}{z1}}{z1} \]
      11. lower-*.f6438.1%

        \[\leadsto \frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - \left(0.5 \cdot z0\right) \cdot z1}{z1}}{z1} \]
    8. Applied rewrites38.1%

      \[\leadsto \frac{\frac{\left(\log 2 \cdot z1\right) \cdot z1 - \left(0.5 \cdot z0\right) \cdot z1}{z1}}{\color{blue}{z1}} \]

    if -1e12 < (/.f64 (neg.f64 z0) z1)

    1. Initial program 99.3%

      \[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
    2. Taylor expanded in z0 around 0

      \[\leadsto \color{blue}{\log 2 + \frac{-1}{2} \cdot \frac{z0}{z1}} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2} \cdot \frac{z0}{z1}} \]
      2. lower-log.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2}} \cdot \frac{z0}{z1} \]
      3. lower-*.f64N/A

        \[\leadsto \log 2 + \frac{-1}{2} \cdot \color{blue}{\frac{z0}{z1}} \]
      4. lower-/.f6466.4%

        \[\leadsto \log 2 + -0.5 \cdot \frac{z0}{\color{blue}{z1}} \]
    4. Applied rewrites66.4%

      \[\leadsto \color{blue}{\log 2 + -0.5 \cdot \frac{z0}{z1}} \]
    5. Evaluated real constant66.4%

      \[\leadsto 0.6931471805599453 + \color{blue}{-0.5} \cdot \frac{z0}{z1} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 2: 69.1% accurate, 4.0× speedup?

\[\begin{array}{l} \mathbf{if}\;\frac{-z0}{z1} \leq -1 \cdot 10^{+57}:\\ \;\;\;\;z0 \cdot \frac{0.6931471805599453 \cdot z1 - 0.5 \cdot z0}{z0 \cdot z1}\\ \mathbf{else}:\\ \;\;\;\;0.6931471805599453 + -0.5 \cdot \frac{z0}{z1}\\ \end{array} \]
(FPCore (z0 z1)
  :precision binary64
  (if (<= (/ (- z0) z1) -1e+57)
  (* z0 (/ (- (* 0.6931471805599453 z1) (* 0.5 z0)) (* z0 z1)))
  (+ 0.6931471805599453 (* -0.5 (/ z0 z1)))))
double code(double z0, double z1) {
	double tmp;
	if ((-z0 / z1) <= -1e+57) {
		tmp = z0 * (((0.6931471805599453 * z1) - (0.5 * z0)) / (z0 * z1));
	} else {
		tmp = 0.6931471805599453 + (-0.5 * (z0 / z1));
	}
	return tmp;
}
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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8) :: tmp
    if ((-z0 / z1) <= (-1d+57)) then
        tmp = z0 * (((0.6931471805599453d0 * z1) - (0.5d0 * z0)) / (z0 * z1))
    else
        tmp = 0.6931471805599453d0 + ((-0.5d0) * (z0 / z1))
    end if
    code = tmp
end function
public static double code(double z0, double z1) {
	double tmp;
	if ((-z0 / z1) <= -1e+57) {
		tmp = z0 * (((0.6931471805599453 * z1) - (0.5 * z0)) / (z0 * z1));
	} else {
		tmp = 0.6931471805599453 + (-0.5 * (z0 / z1));
	}
	return tmp;
}
def code(z0, z1):
	tmp = 0
	if (-z0 / z1) <= -1e+57:
		tmp = z0 * (((0.6931471805599453 * z1) - (0.5 * z0)) / (z0 * z1))
	else:
		tmp = 0.6931471805599453 + (-0.5 * (z0 / z1))
	return tmp
function code(z0, z1)
	tmp = 0.0
	if (Float64(Float64(-z0) / z1) <= -1e+57)
		tmp = Float64(z0 * Float64(Float64(Float64(0.6931471805599453 * z1) - Float64(0.5 * z0)) / Float64(z0 * z1)));
	else
		tmp = Float64(0.6931471805599453 + Float64(-0.5 * Float64(z0 / z1)));
	end
	return tmp
end
function tmp_2 = code(z0, z1)
	tmp = 0.0;
	if ((-z0 / z1) <= -1e+57)
		tmp = z0 * (((0.6931471805599453 * z1) - (0.5 * z0)) / (z0 * z1));
	else
		tmp = 0.6931471805599453 + (-0.5 * (z0 / z1));
	end
	tmp_2 = tmp;
end
code[z0_, z1_] := If[LessEqual[N[((-z0) / z1), $MachinePrecision], -1e+57], N[(z0 * N[(N[(N[(0.6931471805599453 * z1), $MachinePrecision] - N[(0.5 * z0), $MachinePrecision]), $MachinePrecision] / N[(z0 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.6931471805599453 + N[(-0.5 * N[(z0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{-z0}{z1} \leq -1 \cdot 10^{+57}:\\
\;\;\;\;z0 \cdot \frac{0.6931471805599453 \cdot z1 - 0.5 \cdot z0}{z0 \cdot z1}\\

\mathbf{else}:\\
\;\;\;\;0.6931471805599453 + -0.5 \cdot \frac{z0}{z1}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (neg.f64 z0) z1) < -1e57

    1. Initial program 99.3%

      \[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
    2. Taylor expanded in z0 around 0

      \[\leadsto \color{blue}{\log 2 + \frac{-1}{2} \cdot \frac{z0}{z1}} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2} \cdot \frac{z0}{z1}} \]
      2. lower-log.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2}} \cdot \frac{z0}{z1} \]
      3. lower-*.f64N/A

        \[\leadsto \log 2 + \frac{-1}{2} \cdot \color{blue}{\frac{z0}{z1}} \]
      4. lower-/.f6466.4%

        \[\leadsto \log 2 + -0.5 \cdot \frac{z0}{\color{blue}{z1}} \]
    4. Applied rewrites66.4%

      \[\leadsto \color{blue}{\log 2 + -0.5 \cdot \frac{z0}{z1}} \]
    5. Taylor expanded in z0 around inf

      \[\leadsto z0 \cdot \color{blue}{\left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \frac{1}{z1}\right)} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \color{blue}{\frac{1}{z1}}\right) \]
      3. lower-/.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \frac{\color{blue}{1}}{z1}\right) \]
      4. lower-log.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \frac{1}{z1}\right) \]
      5. lower-*.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - \frac{1}{2} \cdot \frac{1}{\color{blue}{z1}}\right) \]
      6. lower-/.f6466.3%

        \[\leadsto z0 \cdot \left(\frac{\log 2}{z0} - 0.5 \cdot \frac{1}{z1}\right) \]
    7. Applied rewrites66.3%

      \[\leadsto z0 \cdot \color{blue}{\left(\frac{\log 2}{z0} - 0.5 \cdot \frac{1}{z1}\right)} \]
    8. Evaluated real constant66.3%

      \[\leadsto z0 \cdot \left(\frac{0.6931471805599453}{z0} - 0.5 \cdot \frac{1}{z1}\right) \]
    9. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} - \frac{1}{2} \cdot \color{blue}{\frac{1}{z1}}\right) \]
      2. lift-*.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} - \frac{1}{2} \cdot \frac{1}{\color{blue}{z1}}\right) \]
      3. fp-cancel-sub-sign-invN/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \color{blue}{\frac{1}{z1}}\right) \]
      4. lift-/.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \frac{\color{blue}{1}}{z1}\right) \]
      5. metadata-evalN/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \frac{-1}{2} \cdot \frac{1}{z1}\right) \]
      6. lift-/.f64N/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \frac{-1}{2} \cdot \frac{1}{z1}\right) \]
      7. mult-flipN/A

        \[\leadsto z0 \cdot \left(\frac{\frac{6243314768165359}{9007199254740992}}{z0} + \frac{\frac{-1}{2}}{z1}\right) \]
      8. common-denominatorN/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 + \frac{-1}{2} \cdot z0}{z0 \cdot \color{blue}{z1}} \]
      9. lower-/.f64N/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 + \frac{-1}{2} \cdot z0}{z0 \cdot \color{blue}{z1}} \]
      10. fp-cancel-sign-sub-invN/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) \cdot z0}{z0 \cdot z1} \]
      11. metadata-evalN/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \frac{1}{2} \cdot z0}{z0 \cdot z1} \]
      12. lower--.f64N/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \frac{1}{2} \cdot z0}{z0 \cdot z1} \]
      13. lower-*.f64N/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \frac{1}{2} \cdot z0}{z0 \cdot z1} \]
      14. lower-*.f64N/A

        \[\leadsto z0 \cdot \frac{\frac{6243314768165359}{9007199254740992} \cdot z1 - \frac{1}{2} \cdot z0}{z0 \cdot z1} \]
      15. lower-*.f6455.3%

        \[\leadsto z0 \cdot \frac{0.6931471805599453 \cdot z1 - 0.5 \cdot z0}{z0 \cdot z1} \]
    10. Applied rewrites55.3%

      \[\leadsto z0 \cdot \frac{0.6931471805599453 \cdot z1 - 0.5 \cdot z0}{z0 \cdot \color{blue}{z1}} \]

    if -1e57 < (/.f64 (neg.f64 z0) z1)

    1. Initial program 99.3%

      \[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
    2. Taylor expanded in z0 around 0

      \[\leadsto \color{blue}{\log 2 + \frac{-1}{2} \cdot \frac{z0}{z1}} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2} \cdot \frac{z0}{z1}} \]
      2. lower-log.f64N/A

        \[\leadsto \log 2 + \color{blue}{\frac{-1}{2}} \cdot \frac{z0}{z1} \]
      3. lower-*.f64N/A

        \[\leadsto \log 2 + \frac{-1}{2} \cdot \color{blue}{\frac{z0}{z1}} \]
      4. lower-/.f6466.4%

        \[\leadsto \log 2 + -0.5 \cdot \frac{z0}{\color{blue}{z1}} \]
    4. Applied rewrites66.4%

      \[\leadsto \color{blue}{\log 2 + -0.5 \cdot \frac{z0}{z1}} \]
    5. Evaluated real constant66.4%

      \[\leadsto 0.6931471805599453 + \color{blue}{-0.5} \cdot \frac{z0}{z1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 66.4% accurate, 10.9× speedup?

\[0.6931471805599453 + -0.5 \cdot \frac{z0}{z1} \]
(FPCore (z0 z1)
  :precision binary64
  (+ 0.6931471805599453 (* -0.5 (/ z0 z1))))
double code(double z0, double z1) {
	return 0.6931471805599453 + (-0.5 * (z0 / z1));
}
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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    code = 0.6931471805599453d0 + ((-0.5d0) * (z0 / z1))
end function
public static double code(double z0, double z1) {
	return 0.6931471805599453 + (-0.5 * (z0 / z1));
}
def code(z0, z1):
	return 0.6931471805599453 + (-0.5 * (z0 / z1))
function code(z0, z1)
	return Float64(0.6931471805599453 + Float64(-0.5 * Float64(z0 / z1)))
end
function tmp = code(z0, z1)
	tmp = 0.6931471805599453 + (-0.5 * (z0 / z1));
end
code[z0_, z1_] := N[(0.6931471805599453 + N[(-0.5 * N[(z0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
0.6931471805599453 + -0.5 \cdot \frac{z0}{z1}
Derivation
  1. Initial program 99.3%

    \[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
  2. Taylor expanded in z0 around 0

    \[\leadsto \color{blue}{\log 2 + \frac{-1}{2} \cdot \frac{z0}{z1}} \]
  3. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \log 2 + \color{blue}{\frac{-1}{2} \cdot \frac{z0}{z1}} \]
    2. lower-log.f64N/A

      \[\leadsto \log 2 + \color{blue}{\frac{-1}{2}} \cdot \frac{z0}{z1} \]
    3. lower-*.f64N/A

      \[\leadsto \log 2 + \frac{-1}{2} \cdot \color{blue}{\frac{z0}{z1}} \]
    4. lower-/.f6466.4%

      \[\leadsto \log 2 + -0.5 \cdot \frac{z0}{\color{blue}{z1}} \]
  4. Applied rewrites66.4%

    \[\leadsto \color{blue}{\log 2 + -0.5 \cdot \frac{z0}{z1}} \]
  5. Evaluated real constant66.4%

    \[\leadsto 0.6931471805599453 + \color{blue}{-0.5} \cdot \frac{z0}{z1} \]
  6. Add Preprocessing

Alternative 4: 65.9% accurate, 217.0× speedup?

\[0.6931471805599453 \]
(FPCore (z0 z1)
  :precision binary64
  0.6931471805599453)
double code(double z0, double z1) {
	return 0.6931471805599453;
}
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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    code = 0.6931471805599453d0
end function
public static double code(double z0, double z1) {
	return 0.6931471805599453;
}
def code(z0, z1):
	return 0.6931471805599453
function code(z0, z1)
	return 0.6931471805599453
end
function tmp = code(z0, z1)
	tmp = 0.6931471805599453;
end
code[z0_, z1_] := 0.6931471805599453
0.6931471805599453
Derivation
  1. Initial program 99.3%

    \[\log \left(e^{\frac{-z0}{z1}} - -1\right) \]
  2. Taylor expanded in z0 around 0

    \[\leadsto \color{blue}{\log 2 + \frac{-1}{2} \cdot \frac{z0}{z1}} \]
  3. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \log 2 + \color{blue}{\frac{-1}{2} \cdot \frac{z0}{z1}} \]
    2. lower-log.f64N/A

      \[\leadsto \log 2 + \color{blue}{\frac{-1}{2}} \cdot \frac{z0}{z1} \]
    3. lower-*.f64N/A

      \[\leadsto \log 2 + \frac{-1}{2} \cdot \color{blue}{\frac{z0}{z1}} \]
    4. lower-/.f6466.4%

      \[\leadsto \log 2 + -0.5 \cdot \frac{z0}{\color{blue}{z1}} \]
  4. Applied rewrites66.4%

    \[\leadsto \color{blue}{\log 2 + -0.5 \cdot \frac{z0}{z1}} \]
  5. Evaluated real constant66.4%

    \[\leadsto 0.6931471805599453 + \color{blue}{-0.5} \cdot \frac{z0}{z1} \]
  6. Taylor expanded in z0 around 0

    \[\leadsto \frac{6243314768165359}{9007199254740992} \]
  7. Step-by-step derivation
    1. Applied rewrites65.9%

      \[\leadsto 0.6931471805599453 \]
    2. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025250 
    (FPCore (z0 z1)
      :name "(log (- (exp (/ (- z0) z1)) -1))"
      :precision binary64
      (log (- (exp (/ (- z0) z1)) -1.0)))