
(FPCore (z0) :precision binary64 (/ 1.0 (* PI z0)))
double code(double z0) {
return 1.0 / (((double) M_PI) * z0);
}
public static double code(double z0) {
return 1.0 / (Math.PI * z0);
}
def code(z0): return 1.0 / (math.pi * z0)
function code(z0) return Float64(1.0 / Float64(pi * z0)) end
function tmp = code(z0) tmp = 1.0 / (pi * z0); end
code[z0_] := N[(1.0 / N[(Pi * z0), $MachinePrecision]), $MachinePrecision]
\frac{1}{\pi \cdot z0}
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0) :precision binary64 (/ 1.0 (* PI z0)))
double code(double z0) {
return 1.0 / (((double) M_PI) * z0);
}
public static double code(double z0) {
return 1.0 / (Math.PI * z0);
}
def code(z0): return 1.0 / (math.pi * z0)
function code(z0) return Float64(1.0 / Float64(pi * z0)) end
function tmp = code(z0) tmp = 1.0 / (pi * z0); end
code[z0_] := N[(1.0 / N[(Pi * z0), $MachinePrecision]), $MachinePrecision]
\frac{1}{\pi \cdot z0}
(FPCore (z0) :precision binary64 (* (/ (/ 1.0 (* PI PI)) z0) PI))
double code(double z0) {
return ((1.0 / (((double) M_PI) * ((double) M_PI))) / z0) * ((double) M_PI);
}
public static double code(double z0) {
return ((1.0 / (Math.PI * Math.PI)) / z0) * Math.PI;
}
def code(z0): return ((1.0 / (math.pi * math.pi)) / z0) * math.pi
function code(z0) return Float64(Float64(Float64(1.0 / Float64(pi * pi)) / z0) * pi) end
function tmp = code(z0) tmp = ((1.0 / (pi * pi)) / z0) * pi; end
code[z0_] := N[(N[(N[(1.0 / N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] / z0), $MachinePrecision] * Pi), $MachinePrecision]
\frac{\frac{1}{\pi \cdot \pi}}{z0} \cdot \pi
Initial program 99.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.5%
Applied rewrites99.5%
Applied rewrites99.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.2%
Applied rewrites99.2%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
frac-timesN/A
mult-flipN/A
lower-/.f64N/A
lower-/.f6499.6%
Applied rewrites99.6%
(FPCore (z0) :precision binary64 (/ (/ PI z0) 9.869604401089358))
double code(double z0) {
return (((double) M_PI) / z0) / 9.869604401089358;
}
public static double code(double z0) {
return (Math.PI / z0) / 9.869604401089358;
}
def code(z0): return (math.pi / z0) / 9.869604401089358
function code(z0) return Float64(Float64(pi / z0) / 9.869604401089358) end
function tmp = code(z0) tmp = (pi / z0) / 9.869604401089358; end
code[z0_] := N[(N[(Pi / z0), $MachinePrecision] / 9.869604401089358), $MachinePrecision]
\frac{\frac{\pi}{z0}}{9.869604401089358}
Initial program 99.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.5%
Applied rewrites99.5%
Applied rewrites99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6499.5%
Applied rewrites99.5%
Evaluated real constant99.5%
(FPCore (z0) :precision binary64 (/ 0.3183098861837907 z0))
double code(double z0) {
return 0.3183098861837907 / 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 = 0.3183098861837907d0 / z0
end function
public static double code(double z0) {
return 0.3183098861837907 / z0;
}
def code(z0): return 0.3183098861837907 / z0
function code(z0) return Float64(0.3183098861837907 / z0) end
function tmp = code(z0) tmp = 0.3183098861837907 / z0; end
code[z0_] := N[(0.3183098861837907 / z0), $MachinePrecision]
\frac{0.3183098861837907}{z0}
Initial program 99.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.4%
Applied rewrites99.4%
Evaluated real constant99.4%
herbie shell --seed 2025250
(FPCore (z0)
:name "(/ 1 (* PI z0))"
:precision binary64
(/ 1.0 (* PI z0)))