
(FPCore (z0) :precision binary64 (- (sqrt PI) (* (- 1.5 (* 0.5 z0)) z0)))
double code(double z0) {
return sqrt(((double) M_PI)) - ((1.5 - (0.5 * z0)) * z0);
}
public static double code(double z0) {
return Math.sqrt(Math.PI) - ((1.5 - (0.5 * z0)) * z0);
}
def code(z0): return math.sqrt(math.pi) - ((1.5 - (0.5 * z0)) * z0)
function code(z0) return Float64(sqrt(pi) - Float64(Float64(1.5 - Float64(0.5 * z0)) * z0)) end
function tmp = code(z0) tmp = sqrt(pi) - ((1.5 - (0.5 * z0)) * z0); end
code[z0_] := N[(N[Sqrt[Pi], $MachinePrecision] - N[(N[(1.5 - N[(0.5 * z0), $MachinePrecision]), $MachinePrecision] * z0), $MachinePrecision]), $MachinePrecision]
\sqrt{\pi} - \left(1.5 - 0.5 \cdot z0\right) \cdot z0
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0) :precision binary64 (- (sqrt PI) (* (- 1.5 (* 0.5 z0)) z0)))
double code(double z0) {
return sqrt(((double) M_PI)) - ((1.5 - (0.5 * z0)) * z0);
}
public static double code(double z0) {
return Math.sqrt(Math.PI) - ((1.5 - (0.5 * z0)) * z0);
}
def code(z0): return math.sqrt(math.pi) - ((1.5 - (0.5 * z0)) * z0)
function code(z0) return Float64(sqrt(pi) - Float64(Float64(1.5 - Float64(0.5 * z0)) * z0)) end
function tmp = code(z0) tmp = sqrt(pi) - ((1.5 - (0.5 * z0)) * z0); end
code[z0_] := N[(N[Sqrt[Pi], $MachinePrecision] - N[(N[(1.5 - N[(0.5 * z0), $MachinePrecision]), $MachinePrecision] * z0), $MachinePrecision]), $MachinePrecision]
\sqrt{\pi} - \left(1.5 - 0.5 \cdot z0\right) \cdot z0
(FPCore (z0) :precision binary64 (- 1.772453850905516 (- (* (* -0.5 z0) z0) (* -1.5 z0))))
double code(double z0) {
return 1.772453850905516 - (((-0.5 * z0) * z0) - (-1.5 * 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 = 1.772453850905516d0 - ((((-0.5d0) * z0) * z0) - ((-1.5d0) * z0))
end function
public static double code(double z0) {
return 1.772453850905516 - (((-0.5 * z0) * z0) - (-1.5 * z0));
}
def code(z0): return 1.772453850905516 - (((-0.5 * z0) * z0) - (-1.5 * z0))
function code(z0) return Float64(1.772453850905516 - Float64(Float64(Float64(-0.5 * z0) * z0) - Float64(-1.5 * z0))) end
function tmp = code(z0) tmp = 1.772453850905516 - (((-0.5 * z0) * z0) - (-1.5 * z0)); end
code[z0_] := N[(1.772453850905516 - N[(N[(N[(-0.5 * z0), $MachinePrecision] * z0), $MachinePrecision] - N[(-1.5 * z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1.772453850905516 - \left(\left(-0.5 \cdot z0\right) \cdot z0 - -1.5 \cdot z0\right)
Initial program 99.2%
Evaluated real constant100.0%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-*.f64N/A
distribute-rgt-outN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64100.0%
Applied rewrites100.0%
(FPCore (z0) :precision binary64 (- 1.772453850905516 (* (- 1.5 (* 0.5 z0)) z0)))
double code(double z0) {
return 1.772453850905516 - ((1.5 - (0.5 * z0)) * 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 = 1.772453850905516d0 - ((1.5d0 - (0.5d0 * z0)) * z0)
end function
public static double code(double z0) {
return 1.772453850905516 - ((1.5 - (0.5 * z0)) * z0);
}
def code(z0): return 1.772453850905516 - ((1.5 - (0.5 * z0)) * z0)
function code(z0) return Float64(1.772453850905516 - Float64(Float64(1.5 - Float64(0.5 * z0)) * z0)) end
function tmp = code(z0) tmp = 1.772453850905516 - ((1.5 - (0.5 * z0)) * z0); end
code[z0_] := N[(1.772453850905516 - N[(N[(1.5 - N[(0.5 * z0), $MachinePrecision]), $MachinePrecision] * z0), $MachinePrecision]), $MachinePrecision]
1.772453850905516 - \left(1.5 - 0.5 \cdot z0\right) \cdot z0
Initial program 99.2%
Evaluated real constant100.0%
(FPCore (z0) :precision binary64 (- 1.772453850905516 (* (* -0.5 z0) z0)))
double code(double z0) {
return 1.772453850905516 - ((-0.5 * z0) * 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 = 1.772453850905516d0 - (((-0.5d0) * z0) * z0)
end function
public static double code(double z0) {
return 1.772453850905516 - ((-0.5 * z0) * z0);
}
def code(z0): return 1.772453850905516 - ((-0.5 * z0) * z0)
function code(z0) return Float64(1.772453850905516 - Float64(Float64(-0.5 * z0) * z0)) end
function tmp = code(z0) tmp = 1.772453850905516 - ((-0.5 * z0) * z0); end
code[z0_] := N[(1.772453850905516 - N[(N[(-0.5 * z0), $MachinePrecision] * z0), $MachinePrecision]), $MachinePrecision]
1.772453850905516 - \left(-0.5 \cdot z0\right) \cdot z0
Initial program 99.2%
Evaluated real constant100.0%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-*.f64N/A
distribute-rgt-outN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64100.0%
Applied rewrites100.0%
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--l-N/A
sub-negateN/A
lower--.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval100.0%
Applied rewrites100.0%
Taylor expanded in z0 around 0
Applied rewrites97.9%
(FPCore (z0) :precision binary64 (- 1.772453850905516 (* 1.5 z0)))
double code(double z0) {
return 1.772453850905516 - (1.5 * 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 = 1.772453850905516d0 - (1.5d0 * z0)
end function
public static double code(double z0) {
return 1.772453850905516 - (1.5 * z0);
}
def code(z0): return 1.772453850905516 - (1.5 * z0)
function code(z0) return Float64(1.772453850905516 - Float64(1.5 * z0)) end
function tmp = code(z0) tmp = 1.772453850905516 - (1.5 * z0); end
code[z0_] := N[(1.772453850905516 - N[(1.5 * z0), $MachinePrecision]), $MachinePrecision]
1.772453850905516 - 1.5 \cdot z0
Initial program 99.2%
Evaluated real constant100.0%
Taylor expanded in z0 around 0
Applied rewrites52.1%
(FPCore (z0) :precision binary64 1.772453850905516)
double code(double z0) {
return 1.772453850905516;
}
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 = 1.772453850905516d0
end function
public static double code(double z0) {
return 1.772453850905516;
}
def code(z0): return 1.772453850905516
function code(z0) return 1.772453850905516 end
function tmp = code(z0) tmp = 1.772453850905516; end
code[z0_] := 1.772453850905516
1.772453850905516
Initial program 99.2%
Evaluated real constant100.0%
Taylor expanded in z0 around 0
Applied rewrites51.8%
herbie shell --seed 2025250
(FPCore (z0)
:name "(- (sqrt PI) (* (- 3/2 (* 1/2 z0)) z0))"
:precision binary64
(- (sqrt PI) (* (- 1.5 (* 0.5 z0)) z0)))