
(FPCore (z0) :precision binary64 (- 41.341702240407926 (* (* z0 z0) 81.6052492761019)))
double code(double z0) {
return 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
}
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 = 41.341702240407926d0 - ((z0 * z0) * 81.6052492761019d0)
end function
public static double code(double z0) {
return 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
}
def code(z0): return 41.341702240407926 - ((z0 * z0) * 81.6052492761019)
function code(z0) return Float64(41.341702240407926 - Float64(Float64(z0 * z0) * 81.6052492761019)) end
function tmp = code(z0) tmp = 41.341702240407926 - ((z0 * z0) * 81.6052492761019); end
code[z0_] := N[(41.341702240407926 - N[(N[(z0 * z0), $MachinePrecision] * 81.6052492761019), $MachinePrecision]), $MachinePrecision]
41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0) :precision binary64 (- 41.341702240407926 (* (* z0 z0) 81.6052492761019)))
double code(double z0) {
return 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
}
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 = 41.341702240407926d0 - ((z0 * z0) * 81.6052492761019d0)
end function
public static double code(double z0) {
return 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
}
def code(z0): return 41.341702240407926 - ((z0 * z0) * 81.6052492761019)
function code(z0) return Float64(41.341702240407926 - Float64(Float64(z0 * z0) * 81.6052492761019)) end
function tmp = code(z0) tmp = 41.341702240407926 - ((z0 * z0) * 81.6052492761019); end
code[z0_] := N[(41.341702240407926 - N[(N[(z0 * z0), $MachinePrecision] * 81.6052492761019), $MachinePrecision]), $MachinePrecision]
41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019
(FPCore (z0) :precision binary64 (* (- (* z0 z0) 0.5066059182116223) -81.6052492761019))
double code(double z0) {
return ((z0 * z0) - 0.5066059182116223) * -81.6052492761019;
}
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 = ((z0 * z0) - 0.5066059182116223d0) * (-81.6052492761019d0)
end function
public static double code(double z0) {
return ((z0 * z0) - 0.5066059182116223) * -81.6052492761019;
}
def code(z0): return ((z0 * z0) - 0.5066059182116223) * -81.6052492761019
function code(z0) return Float64(Float64(Float64(z0 * z0) - 0.5066059182116223) * -81.6052492761019) end
function tmp = code(z0) tmp = ((z0 * z0) - 0.5066059182116223) * -81.6052492761019; end
code[z0_] := N[(N[(N[(z0 * z0), $MachinePrecision] - 0.5066059182116223), $MachinePrecision] * -81.6052492761019), $MachinePrecision]
\left(z0 \cdot z0 - 0.5066059182116223\right) \cdot -81.6052492761019
Initial program 99.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqr-neg-revN/A
associate-*r*N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-*.f6499.9%
Applied rewrites99.9%
Applied rewrites74.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
Applied rewrites99.7%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
associate-*l/N/A
metadata-evalN/A
associate-*r*N/A
mult-flipN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
sub-divN/A
associate-/r/N/A
lift-/.f64N/A
sub-to-fractionN/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
lift-*.f64N/A
sub-to-fractionN/A
metadata-evalN/A
Applied rewrites99.9%
(FPCore (z0)
:precision binary64
(if (<=
(- 41.341702240407926 (* (* z0 z0) 81.6052492761019))
-200000.0)
(* (* -81.6052492761019 z0) z0)
41.341702240407926))double code(double z0) {
double tmp;
if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) {
tmp = (-81.6052492761019 * z0) * z0;
} else {
tmp = 41.341702240407926;
}
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 ((41.341702240407926d0 - ((z0 * z0) * 81.6052492761019d0)) <= (-200000.0d0)) then
tmp = ((-81.6052492761019d0) * z0) * z0
else
tmp = 41.341702240407926d0
end if
code = tmp
end function
public static double code(double z0) {
double tmp;
if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) {
tmp = (-81.6052492761019 * z0) * z0;
} else {
tmp = 41.341702240407926;
}
return tmp;
}
def code(z0): tmp = 0 if (41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0: tmp = (-81.6052492761019 * z0) * z0 else: tmp = 41.341702240407926 return tmp
function code(z0) tmp = 0.0 if (Float64(41.341702240407926 - Float64(Float64(z0 * z0) * 81.6052492761019)) <= -200000.0) tmp = Float64(Float64(-81.6052492761019 * z0) * z0); else tmp = 41.341702240407926; end return tmp end
function tmp_2 = code(z0) tmp = 0.0; if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) tmp = (-81.6052492761019 * z0) * z0; else tmp = 41.341702240407926; end tmp_2 = tmp; end
code[z0_] := If[LessEqual[N[(41.341702240407926 - N[(N[(z0 * z0), $MachinePrecision] * 81.6052492761019), $MachinePrecision]), $MachinePrecision], -200000.0], N[(N[(-81.6052492761019 * z0), $MachinePrecision] * z0), $MachinePrecision], 41.341702240407926]
\begin{array}{l}
\mathbf{if}\;41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \leq -200000:\\
\;\;\;\;\left(-81.6052492761019 \cdot z0\right) \cdot z0\\
\mathbf{else}:\\
\;\;\;\;41.341702240407926\\
\end{array}
if (-.f64 #s(literal 20670851120203963/500000000000000 binary64) (*.f64 (*.f64 z0 z0) #s(literal 816052492761019/10000000000000 binary64))) < -2e5Initial program 99.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqr-neg-revN/A
associate-*r*N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-*.f6499.9%
Applied rewrites99.9%
Applied rewrites74.6%
Taylor expanded in z0 around inf
Applied rewrites50.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6450.0%
Applied rewrites50.0%
if -2e5 < (-.f64 #s(literal 20670851120203963/500000000000000 binary64) (*.f64 (*.f64 z0 z0) #s(literal 816052492761019/10000000000000 binary64))) Initial program 99.9%
Taylor expanded in z0 around 0
Applied rewrites50.6%
(FPCore (z0)
:precision binary64
(if (<=
(- 41.341702240407926 (* (* z0 z0) 81.6052492761019))
-200000.0)
(* -81.6052492761019 (* z0 z0))
41.341702240407926))double code(double z0) {
double tmp;
if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) {
tmp = -81.6052492761019 * (z0 * z0);
} else {
tmp = 41.341702240407926;
}
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 ((41.341702240407926d0 - ((z0 * z0) * 81.6052492761019d0)) <= (-200000.0d0)) then
tmp = (-81.6052492761019d0) * (z0 * z0)
else
tmp = 41.341702240407926d0
end if
code = tmp
end function
public static double code(double z0) {
double tmp;
if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) {
tmp = -81.6052492761019 * (z0 * z0);
} else {
tmp = 41.341702240407926;
}
return tmp;
}
def code(z0): tmp = 0 if (41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0: tmp = -81.6052492761019 * (z0 * z0) else: tmp = 41.341702240407926 return tmp
function code(z0) tmp = 0.0 if (Float64(41.341702240407926 - Float64(Float64(z0 * z0) * 81.6052492761019)) <= -200000.0) tmp = Float64(-81.6052492761019 * Float64(z0 * z0)); else tmp = 41.341702240407926; end return tmp end
function tmp_2 = code(z0) tmp = 0.0; if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) tmp = -81.6052492761019 * (z0 * z0); else tmp = 41.341702240407926; end tmp_2 = tmp; end
code[z0_] := If[LessEqual[N[(41.341702240407926 - N[(N[(z0 * z0), $MachinePrecision] * 81.6052492761019), $MachinePrecision]), $MachinePrecision], -200000.0], N[(-81.6052492761019 * N[(z0 * z0), $MachinePrecision]), $MachinePrecision], 41.341702240407926]
\begin{array}{l}
\mathbf{if}\;41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \leq -200000:\\
\;\;\;\;-81.6052492761019 \cdot \left(z0 \cdot z0\right)\\
\mathbf{else}:\\
\;\;\;\;41.341702240407926\\
\end{array}
if (-.f64 #s(literal 20670851120203963/500000000000000 binary64) (*.f64 (*.f64 z0 z0) #s(literal 816052492761019/10000000000000 binary64))) < -2e5Initial program 99.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqr-neg-revN/A
associate-*r*N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-*.f6499.9%
Applied rewrites99.9%
Applied rewrites74.6%
Taylor expanded in z0 around inf
Applied rewrites50.0%
if -2e5 < (-.f64 #s(literal 20670851120203963/500000000000000 binary64) (*.f64 (*.f64 z0 z0) #s(literal 816052492761019/10000000000000 binary64))) Initial program 99.9%
Taylor expanded in z0 around 0
Applied rewrites50.6%
(FPCore (z0) :precision binary64 41.341702240407926)
double code(double z0) {
return 41.341702240407926;
}
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 = 41.341702240407926d0
end function
public static double code(double z0) {
return 41.341702240407926;
}
def code(z0): return 41.341702240407926
function code(z0) return 41.341702240407926 end
function tmp = code(z0) tmp = 41.341702240407926; end
code[z0_] := 41.341702240407926
41.341702240407926
Initial program 99.9%
Taylor expanded in z0 around 0
Applied rewrites50.6%
herbie shell --seed 2025250
(FPCore (z0)
:name "(- 20670851120203963/500000000000000 (* (* z0 z0) 816052492761019/10000000000000))"
:precision binary64
(- 41.341702240407926 (* (* z0 z0) 81.6052492761019)))