
(FPCore (z0) :precision binary64 (log (fabs (log (- 1.0 z0)))))
double code(double z0) {
return log(fabs(log((1.0 - z0))));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = log(abs(log((1.0d0 - z0))))
end function
public static double code(double z0) {
return Math.log(Math.abs(Math.log((1.0 - z0))));
}
def code(z0): return math.log(math.fabs(math.log((1.0 - z0))))
function code(z0) return log(abs(log(Float64(1.0 - z0)))) end
function tmp = code(z0) tmp = log(abs(log((1.0 - z0)))); end
code[z0_] := N[Log[N[Abs[N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\log \left(\left|\log \left(1 - z0\right)\right|\right)
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0) :precision binary64 (log (fabs (log (- 1.0 z0)))))
double code(double z0) {
return log(fabs(log((1.0 - z0))));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = log(abs(log((1.0d0 - z0))))
end function
public static double code(double z0) {
return Math.log(Math.abs(Math.log((1.0 - z0))));
}
def code(z0): return math.log(math.fabs(math.log((1.0 - z0))))
function code(z0) return log(abs(log(Float64(1.0 - z0)))) end
function tmp = code(z0) tmp = log(abs(log((1.0 - z0)))); end
code[z0_] := N[Log[N[Abs[N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\log \left(\left|\log \left(1 - z0\right)\right|\right)
(FPCore (z0) :precision binary64 (if (<= z0 -4.5e-5) (log (fabs (log (- 1.0 z0)))) (log (fabs (* z0 (- (* z0 (- (* -0.3333333333333333 z0) 0.5)) 1.0))))))
double code(double z0) {
double tmp;
if (z0 <= -4.5e-5) {
tmp = log(fabs(log((1.0 - z0))));
} else {
tmp = log(fabs((z0 * ((z0 * ((-0.3333333333333333 * z0) - 0.5)) - 1.0))));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8) :: tmp
if (z0 <= (-4.5d-5)) then
tmp = log(abs(log((1.0d0 - z0))))
else
tmp = log(abs((z0 * ((z0 * (((-0.3333333333333333d0) * z0) - 0.5d0)) - 1.0d0))))
end if
code = tmp
end function
public static double code(double z0) {
double tmp;
if (z0 <= -4.5e-5) {
tmp = Math.log(Math.abs(Math.log((1.0 - z0))));
} else {
tmp = Math.log(Math.abs((z0 * ((z0 * ((-0.3333333333333333 * z0) - 0.5)) - 1.0))));
}
return tmp;
}
def code(z0): tmp = 0 if z0 <= -4.5e-5: tmp = math.log(math.fabs(math.log((1.0 - z0)))) else: tmp = math.log(math.fabs((z0 * ((z0 * ((-0.3333333333333333 * z0) - 0.5)) - 1.0)))) return tmp
function code(z0) tmp = 0.0 if (z0 <= -4.5e-5) tmp = log(abs(log(Float64(1.0 - z0)))); else tmp = log(abs(Float64(z0 * Float64(Float64(z0 * Float64(Float64(-0.3333333333333333 * z0) - 0.5)) - 1.0)))); end return tmp end
function tmp_2 = code(z0) tmp = 0.0; if (z0 <= -4.5e-5) tmp = log(abs(log((1.0 - z0)))); else tmp = log(abs((z0 * ((z0 * ((-0.3333333333333333 * z0) - 0.5)) - 1.0)))); end tmp_2 = tmp; end
code[z0_] := If[LessEqual[z0, -4.5e-5], N[Log[N[Abs[N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Log[N[Abs[N[(z0 * N[(N[(z0 * N[(N[(-0.3333333333333333 * z0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z0 \leq -4.5 \cdot 10^{-5}:\\
\;\;\;\;\log \left(\left|\log \left(1 - z0\right)\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\left|z0 \cdot \left(z0 \cdot \left(-0.3333333333333333 \cdot z0 - 0.5\right) - 1\right)\right|\right)\\
\end{array}
if z0 < -4.5000000000000003e-5Initial program 38.1%
if -4.5000000000000003e-5 < z0 Initial program 38.1%
Taylor expanded in z0 around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6468.1%
Applied rewrites68.1%
(FPCore (z0) :precision binary64 (log (fabs (- z0))))
double code(double z0) {
return log(fabs(-z0));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = log(abs(-z0))
end function
public static double code(double z0) {
return Math.log(Math.abs(-z0));
}
def code(z0): return math.log(math.fabs(-z0))
function code(z0) return log(abs(Float64(-z0))) end
function tmp = code(z0) tmp = log(abs(-z0)); end
code[z0_] := N[Log[N[Abs[(-z0)], $MachinePrecision]], $MachinePrecision]
\log \left(\left|-z0\right|\right)
Initial program 38.1%
Taylor expanded in z0 around 0
lower-*.f6470.0%
Applied rewrites70.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6470.0%
Applied rewrites70.0%
(FPCore (z0) :precision binary64 (log (- z0)))
double code(double z0) {
return log(-z0);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = log(-z0)
end function
public static double code(double z0) {
return Math.log(-z0);
}
def code(z0): return math.log(-z0)
function code(z0) return log(Float64(-z0)) end
function tmp = code(z0) tmp = log(-z0); end
code[z0_] := N[Log[(-z0)], $MachinePrecision]
\log \left(-z0\right)
Initial program 38.1%
Taylor expanded in z0 around 0
lower-*.f6470.0%
Applied rewrites70.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6470.0%
Applied rewrites70.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrt37.6%
Applied rewrites37.6%
herbie shell --seed 2025250
(FPCore (z0)
:name "(log (fabs (log (- 1 z0))))"
:precision binary64
(log (fabs (log (- 1.0 z0)))))