
(FPCore (z0 z1 z2 z3) :precision binary64 (sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3)))
double code(double z0, double z1, double z2, double z3) {
return sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
}
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, z2, z3)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z2
real(8), intent (in) :: z3
code = sqrt(((((-2.0d0) * z0) * (((((z0 - z1) / z2) * z3) - (-2.0d0)) / z2)) * z3))
end function
public static double code(double z0, double z1, double z2, double z3) {
return Math.sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
}
def code(z0, z1, z2, z3): return math.sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3))
function code(z0, z1, z2, z3) return sqrt(Float64(Float64(Float64(-2.0 * z0) * Float64(Float64(Float64(Float64(Float64(z0 - z1) / z2) * z3) - -2.0) / z2)) * z3)) end
function tmp = code(z0, z1, z2, z3) tmp = sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3)); end
code[z0_, z1_, z2_, z3_] := N[Sqrt[N[(N[(N[(-2 * z0), $MachinePrecision] * N[(N[(N[(N[(N[(z0 - z1), $MachinePrecision] / z2), $MachinePrecision] * z3), $MachinePrecision] - -2), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0 z1 z2 z3) :precision binary64 (sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3)))
double code(double z0, double z1, double z2, double z3) {
return sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
}
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, z2, z3)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z2
real(8), intent (in) :: z3
code = sqrt(((((-2.0d0) * z0) * (((((z0 - z1) / z2) * z3) - (-2.0d0)) / z2)) * z3))
end function
public static double code(double z0, double z1, double z2, double z3) {
return Math.sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
}
def code(z0, z1, z2, z3): return math.sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3))
function code(z0, z1, z2, z3) return sqrt(Float64(Float64(Float64(-2.0 * z0) * Float64(Float64(Float64(Float64(Float64(z0 - z1) / z2) * z3) - -2.0) / z2)) * z3)) end
function tmp = code(z0, z1, z2, z3) tmp = sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3)); end
code[z0_, z1_, z2_, z3_] := N[Sqrt[N[(N[(N[(-2 * z0), $MachinePrecision] * N[(N[(N[(N[(N[(z0 - z1), $MachinePrecision] / z2), $MachinePrecision] * z3), $MachinePrecision] - -2), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}
(FPCore (z0 z1 z2 z3)
:precision binary64
(let* ((t_0
(sqrt
(* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3))))
(if (<=
t_0
6183260036827613/123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568)
(/
(sqrt
(304-z0z1z2z3z4 (* z3 -2) (+ z2 z2) z0 (* (- z1 z0) z3) z0))
(fabs z2))
(if (<=
t_0
200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048)
t_0
(/
(sqrt (* (304-z0z1z2z3z4 z0 (- z0 z1) z3 z2 -2) (* z3 -2)))
(fabs z2))))))\begin{array}{l}
t_0 := \sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}\\
\mathbf{if}\;t\_0 \leq \frac{6183260036827613}{123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568}:\\
\;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(\left(z3 \cdot -2\right), \left(z2 + z2\right), z0, \left(\left(z1 - z0\right) \cdot z3\right), z0\right)}}{\left|z2\right|}\\
\mathbf{elif}\;t\_0 \leq 200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\
\end{array}
if (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) < 4.9999999999999997e-158Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites62.7%
if 4.9999999999999997e-158 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) < 2.0000000000000001e140Initial program 59.6%
if 2.0000000000000001e140 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) Initial program 59.6%
Applied rewrites65.5%
lift--.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f6465.5%
lower-*.f64N/A
Applied rewrites64.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
count-2N/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower-304-z0z1z2z3z466.0%
Applied rewrites66.0%
(FPCore (z0 z1 z2 z3)
:precision binary64
(let* ((t_0
(/
(sqrt (* (304-z0z1z2z3z4 z0 (- z0 z1) z3 z2 -2) (* z3 -2)))
(fabs z2)))
(t_1
(sqrt
(* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3))))
(if (<= t_1 0)
t_0
(if (<=
t_1
200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048)
t_1
t_0))))\begin{array}{l}
t_0 := \frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\
t_1 := \sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) < 0.0 or 2.0000000000000001e140 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) Initial program 59.6%
Applied rewrites65.5%
lift--.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f6465.5%
lower-*.f64N/A
Applied rewrites64.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
count-2N/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower-304-z0z1z2z3z466.0%
Applied rewrites66.0%
if 0.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) < 2.0000000000000001e140Initial program 59.6%
(FPCore (z0 z1 z2 z3)
:precision binary64
(let* ((t_0
(/
(sqrt (* (304-z0z1z2z3z4 z0 (- z0 z1) z3 z2 -2) (* z3 -2)))
(fabs z2)))
(t_1 (/ (- z0 z1) z2))
(t_2 (sqrt (* (* (* -2 z0) (/ (- (* t_1 z3) -2) z2)) z3))))
(if (<= t_2 0)
t_0
(if (<=
t_2
200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048)
(sqrt (* (* 2 (- -2 (* z3 t_1))) (/ (* z3 z0) z2)))
t_0))))\begin{array}{l}
t_0 := \frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\
t_1 := \frac{z0 - z1}{z2}\\
t_2 := \sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{t\_1 \cdot z3 - -2}{z2}\right) \cdot z3}\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_2 \leq 200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(-2 - z3 \cdot t\_1\right)\right) \cdot \frac{z3 \cdot z0}{z2}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) < 0.0 or 2.0000000000000001e140 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) Initial program 59.6%
Applied rewrites65.5%
lift--.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f6465.5%
lower-*.f64N/A
Applied rewrites64.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
count-2N/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower-304-z0z1z2z3z466.0%
Applied rewrites66.0%
if 0.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) < 2.0000000000000001e140Initial program 59.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites42.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites61.0%
(FPCore (z0 z1 z2 z3)
:precision binary64
(let* ((t_0 (- (- (* (- z1 z0) z3) z2) z2)))
(if (<= z0 -49999999999999999661047433718081398823085422097203200)
(/ (sqrt (* t_0 (* (+ z0 z0) z3))) (fabs z2))
(if (<=
z0
5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176)
(/
(sqrt (* (304-z0z1z2z3z4 z0 (- z0 z1) z3 z2 -2) (* z3 -2)))
(fabs z2))
(/ (sqrt (* (+ z0 z0) (* z3 t_0))) (fabs z2))))))\begin{array}{l}
t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\
\mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\
\mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\
\;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\
\end{array}
if z0 < -5e52Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6465.6%
Applied rewrites65.6%
if -5e52 < z0 < 5.0000000000000005e105Initial program 59.6%
Applied rewrites65.5%
lift--.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f6465.5%
lower-*.f64N/A
Applied rewrites64.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
count-2N/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower-304-z0z1z2z3z466.0%
Applied rewrites66.0%
if 5.0000000000000005e105 < z0 Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-*.f6462.7%
Applied rewrites62.7%
(FPCore (z0 z1 z2 z3)
:precision binary64
(let* ((t_0 (* (- z1 z0) z3)) (t_1 (- (- t_0 z2) z2)))
(if (<= z0 -49999999999999999661047433718081398823085422097203200)
(/ (sqrt (* t_1 (* (+ z0 z0) z3))) (fabs z2))
(if (<=
z0
5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176)
(/ (sqrt (* (* (- (+ z2 z2) t_0) z0) (* z3 -2))) (fabs z2))
(/ (sqrt (* (+ z0 z0) (* z3 t_1))) (fabs z2))))))double code(double z0, double z1, double z2, double z3) {
double t_0 = (z1 - z0) * z3;
double t_1 = (t_0 - z2) - z2;
double tmp;
if (z0 <= -5e+52) {
tmp = sqrt((t_1 * ((z0 + z0) * z3))) / fabs(z2);
} else if (z0 <= 5e+105) {
tmp = sqrt(((((z2 + z2) - t_0) * z0) * (z3 * -2.0))) / fabs(z2);
} else {
tmp = sqrt(((z0 + z0) * (z3 * t_1))) / fabs(z2);
}
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, z2, z3)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (z1 - z0) * z3
t_1 = (t_0 - z2) - z2
if (z0 <= (-5d+52)) then
tmp = sqrt((t_1 * ((z0 + z0) * z3))) / abs(z2)
else if (z0 <= 5d+105) then
tmp = sqrt(((((z2 + z2) - t_0) * z0) * (z3 * (-2.0d0)))) / abs(z2)
else
tmp = sqrt(((z0 + z0) * (z3 * t_1))) / abs(z2)
end if
code = tmp
end function
public static double code(double z0, double z1, double z2, double z3) {
double t_0 = (z1 - z0) * z3;
double t_1 = (t_0 - z2) - z2;
double tmp;
if (z0 <= -5e+52) {
tmp = Math.sqrt((t_1 * ((z0 + z0) * z3))) / Math.abs(z2);
} else if (z0 <= 5e+105) {
tmp = Math.sqrt(((((z2 + z2) - t_0) * z0) * (z3 * -2.0))) / Math.abs(z2);
} else {
tmp = Math.sqrt(((z0 + z0) * (z3 * t_1))) / Math.abs(z2);
}
return tmp;
}
def code(z0, z1, z2, z3): t_0 = (z1 - z0) * z3 t_1 = (t_0 - z2) - z2 tmp = 0 if z0 <= -5e+52: tmp = math.sqrt((t_1 * ((z0 + z0) * z3))) / math.fabs(z2) elif z0 <= 5e+105: tmp = math.sqrt(((((z2 + z2) - t_0) * z0) * (z3 * -2.0))) / math.fabs(z2) else: tmp = math.sqrt(((z0 + z0) * (z3 * t_1))) / math.fabs(z2) return tmp
function code(z0, z1, z2, z3) t_0 = Float64(Float64(z1 - z0) * z3) t_1 = Float64(Float64(t_0 - z2) - z2) tmp = 0.0 if (z0 <= -5e+52) tmp = Float64(sqrt(Float64(t_1 * Float64(Float64(z0 + z0) * z3))) / abs(z2)); elseif (z0 <= 5e+105) tmp = Float64(sqrt(Float64(Float64(Float64(Float64(z2 + z2) - t_0) * z0) * Float64(z3 * -2.0))) / abs(z2)); else tmp = Float64(sqrt(Float64(Float64(z0 + z0) * Float64(z3 * t_1))) / abs(z2)); end return tmp end
function tmp_2 = code(z0, z1, z2, z3) t_0 = (z1 - z0) * z3; t_1 = (t_0 - z2) - z2; tmp = 0.0; if (z0 <= -5e+52) tmp = sqrt((t_1 * ((z0 + z0) * z3))) / abs(z2); elseif (z0 <= 5e+105) tmp = sqrt(((((z2 + z2) - t_0) * z0) * (z3 * -2.0))) / abs(z2); else tmp = sqrt(((z0 + z0) * (z3 * t_1))) / abs(z2); end tmp_2 = tmp; end
code[z0_, z1_, z2_, z3_] := Block[{t$95$0 = N[(N[(z1 - z0), $MachinePrecision] * z3), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - z2), $MachinePrecision] - z2), $MachinePrecision]}, If[LessEqual[z0, -49999999999999999661047433718081398823085422097203200], N[(N[Sqrt[N[(t$95$1 * N[(N[(z0 + z0), $MachinePrecision] * z3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], If[LessEqual[z0, 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176], N[(N[Sqrt[N[(N[(N[(N[(z2 + z2), $MachinePrecision] - t$95$0), $MachinePrecision] * z0), $MachinePrecision] * N[(z3 * -2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(z0 + z0), $MachinePrecision] * N[(z3 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left(z1 - z0\right) \cdot z3\\
t_1 := \left(t\_0 - z2\right) - z2\\
\mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\
\;\;\;\;\frac{\sqrt{t\_1 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\
\mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\
\;\;\;\;\frac{\sqrt{\left(\left(\left(z2 + z2\right) - t\_0\right) \cdot z0\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_1\right)}}{\left|z2\right|}\\
\end{array}
if z0 < -5e52Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6465.6%
Applied rewrites65.6%
if -5e52 < z0 < 5.0000000000000005e105Initial program 59.6%
Applied rewrites65.5%
lift--.f64N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f6465.5%
lower-*.f64N/A
Applied rewrites64.6%
if 5.0000000000000005e105 < z0 Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-*.f6462.7%
Applied rewrites62.7%
(FPCore (z0 z1 z2 z3)
:precision binary64
(let* ((t_0 (- (- (* (- z1 z0) z3) z2) z2)))
(if (<= z0 -49999999999999999661047433718081398823085422097203200)
(/ (sqrt (* t_0 (* (+ z0 z0) z3))) (fabs z2))
(if (<=
z0
5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176)
(/ (sqrt (* (* t_0 (+ z0 z0)) z3)) (fabs z2))
(/ (sqrt (* (+ z0 z0) (* z3 t_0))) (fabs z2))))))double code(double z0, double z1, double z2, double z3) {
double t_0 = (((z1 - z0) * z3) - z2) - z2;
double tmp;
if (z0 <= -5e+52) {
tmp = sqrt((t_0 * ((z0 + z0) * z3))) / fabs(z2);
} else if (z0 <= 5e+105) {
tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / fabs(z2);
} else {
tmp = sqrt(((z0 + z0) * (z3 * t_0))) / fabs(z2);
}
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, z2, z3)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8) :: t_0
real(8) :: tmp
t_0 = (((z1 - z0) * z3) - z2) - z2
if (z0 <= (-5d+52)) then
tmp = sqrt((t_0 * ((z0 + z0) * z3))) / abs(z2)
else if (z0 <= 5d+105) then
tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / abs(z2)
else
tmp = sqrt(((z0 + z0) * (z3 * t_0))) / abs(z2)
end if
code = tmp
end function
public static double code(double z0, double z1, double z2, double z3) {
double t_0 = (((z1 - z0) * z3) - z2) - z2;
double tmp;
if (z0 <= -5e+52) {
tmp = Math.sqrt((t_0 * ((z0 + z0) * z3))) / Math.abs(z2);
} else if (z0 <= 5e+105) {
tmp = Math.sqrt(((t_0 * (z0 + z0)) * z3)) / Math.abs(z2);
} else {
tmp = Math.sqrt(((z0 + z0) * (z3 * t_0))) / Math.abs(z2);
}
return tmp;
}
def code(z0, z1, z2, z3): t_0 = (((z1 - z0) * z3) - z2) - z2 tmp = 0 if z0 <= -5e+52: tmp = math.sqrt((t_0 * ((z0 + z0) * z3))) / math.fabs(z2) elif z0 <= 5e+105: tmp = math.sqrt(((t_0 * (z0 + z0)) * z3)) / math.fabs(z2) else: tmp = math.sqrt(((z0 + z0) * (z3 * t_0))) / math.fabs(z2) return tmp
function code(z0, z1, z2, z3) t_0 = Float64(Float64(Float64(Float64(z1 - z0) * z3) - z2) - z2) tmp = 0.0 if (z0 <= -5e+52) tmp = Float64(sqrt(Float64(t_0 * Float64(Float64(z0 + z0) * z3))) / abs(z2)); elseif (z0 <= 5e+105) tmp = Float64(sqrt(Float64(Float64(t_0 * Float64(z0 + z0)) * z3)) / abs(z2)); else tmp = Float64(sqrt(Float64(Float64(z0 + z0) * Float64(z3 * t_0))) / abs(z2)); end return tmp end
function tmp_2 = code(z0, z1, z2, z3) t_0 = (((z1 - z0) * z3) - z2) - z2; tmp = 0.0; if (z0 <= -5e+52) tmp = sqrt((t_0 * ((z0 + z0) * z3))) / abs(z2); elseif (z0 <= 5e+105) tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / abs(z2); else tmp = sqrt(((z0 + z0) * (z3 * t_0))) / abs(z2); end tmp_2 = tmp; end
code[z0_, z1_, z2_, z3_] := Block[{t$95$0 = N[(N[(N[(N[(z1 - z0), $MachinePrecision] * z3), $MachinePrecision] - z2), $MachinePrecision] - z2), $MachinePrecision]}, If[LessEqual[z0, -49999999999999999661047433718081398823085422097203200], N[(N[Sqrt[N[(t$95$0 * N[(N[(z0 + z0), $MachinePrecision] * z3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], If[LessEqual[z0, 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176], N[(N[Sqrt[N[(N[(t$95$0 * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(z0 + z0), $MachinePrecision] * N[(z3 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\
\mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\
\mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\
\end{array}
if z0 < -5e52Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6465.6%
Applied rewrites65.6%
if -5e52 < z0 < 5.0000000000000005e105Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6464.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6464.6%
Applied rewrites64.6%
if 5.0000000000000005e105 < z0 Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-*.f6462.7%
Applied rewrites62.7%
(FPCore (z0 z1 z2 z3)
:precision binary64
(let* ((t_0 (- (- (* (- z1 z0) z3) z2) z2))
(t_1 (/ (sqrt (* (+ z0 z0) (* z3 t_0))) (fabs z2))))
(if (<= z0 -49999999999999999661047433718081398823085422097203200)
t_1
(if (<=
z0
5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176)
(/ (sqrt (* (* t_0 (+ z0 z0)) z3)) (fabs z2))
t_1))))double code(double z0, double z1, double z2, double z3) {
double t_0 = (((z1 - z0) * z3) - z2) - z2;
double t_1 = sqrt(((z0 + z0) * (z3 * t_0))) / fabs(z2);
double tmp;
if (z0 <= -5e+52) {
tmp = t_1;
} else if (z0 <= 5e+105) {
tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / fabs(z2);
} else {
tmp = t_1;
}
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, z2, z3)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((z1 - z0) * z3) - z2) - z2
t_1 = sqrt(((z0 + z0) * (z3 * t_0))) / abs(z2)
if (z0 <= (-5d+52)) then
tmp = t_1
else if (z0 <= 5d+105) then
tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / abs(z2)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double z0, double z1, double z2, double z3) {
double t_0 = (((z1 - z0) * z3) - z2) - z2;
double t_1 = Math.sqrt(((z0 + z0) * (z3 * t_0))) / Math.abs(z2);
double tmp;
if (z0 <= -5e+52) {
tmp = t_1;
} else if (z0 <= 5e+105) {
tmp = Math.sqrt(((t_0 * (z0 + z0)) * z3)) / Math.abs(z2);
} else {
tmp = t_1;
}
return tmp;
}
def code(z0, z1, z2, z3): t_0 = (((z1 - z0) * z3) - z2) - z2 t_1 = math.sqrt(((z0 + z0) * (z3 * t_0))) / math.fabs(z2) tmp = 0 if z0 <= -5e+52: tmp = t_1 elif z0 <= 5e+105: tmp = math.sqrt(((t_0 * (z0 + z0)) * z3)) / math.fabs(z2) else: tmp = t_1 return tmp
function code(z0, z1, z2, z3) t_0 = Float64(Float64(Float64(Float64(z1 - z0) * z3) - z2) - z2) t_1 = Float64(sqrt(Float64(Float64(z0 + z0) * Float64(z3 * t_0))) / abs(z2)) tmp = 0.0 if (z0 <= -5e+52) tmp = t_1; elseif (z0 <= 5e+105) tmp = Float64(sqrt(Float64(Float64(t_0 * Float64(z0 + z0)) * z3)) / abs(z2)); else tmp = t_1; end return tmp end
function tmp_2 = code(z0, z1, z2, z3) t_0 = (((z1 - z0) * z3) - z2) - z2; t_1 = sqrt(((z0 + z0) * (z3 * t_0))) / abs(z2); tmp = 0.0; if (z0 <= -5e+52) tmp = t_1; elseif (z0 <= 5e+105) tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / abs(z2); else tmp = t_1; end tmp_2 = tmp; end
code[z0_, z1_, z2_, z3_] := Block[{t$95$0 = N[(N[(N[(N[(z1 - z0), $MachinePrecision] * z3), $MachinePrecision] - z2), $MachinePrecision] - z2), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(z0 + z0), $MachinePrecision] * N[(z3 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z0, -49999999999999999661047433718081398823085422097203200], t$95$1, If[LessEqual[z0, 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176], N[(N[Sqrt[N[(N[(t$95$0 * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\
t_1 := \frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\
\mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z0 < -5e52 or 5.0000000000000005e105 < z0 Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-*.f6462.7%
Applied rewrites62.7%
if -5e52 < z0 < 5.0000000000000005e105Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6464.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6464.6%
Applied rewrites64.6%
(FPCore (z0 z1 z2 z3) :precision binary64 (/ (sqrt (* (* (- (- (* (- z1 z0) z3) z2) z2) (+ z0 z0)) z3)) (fabs z2)))
double code(double z0, double z1, double z2, double z3) {
return sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / fabs(z2);
}
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, z2, z3)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z2
real(8), intent (in) :: z3
code = sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / abs(z2)
end function
public static double code(double z0, double z1, double z2, double z3) {
return Math.sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / Math.abs(z2);
}
def code(z0, z1, z2, z3): return math.sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / math.fabs(z2)
function code(z0, z1, z2, z3) return Float64(sqrt(Float64(Float64(Float64(Float64(Float64(Float64(z1 - z0) * z3) - z2) - z2) * Float64(z0 + z0)) * z3)) / abs(z2)) end
function tmp = code(z0, z1, z2, z3) tmp = sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / abs(z2); end
code[z0_, z1_, z2_, z3_] := N[(N[Sqrt[N[(N[(N[(N[(N[(N[(z1 - z0), $MachinePrecision] * z3), $MachinePrecision] - z2), $MachinePrecision] - z2), $MachinePrecision] * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|}
Initial program 59.6%
Applied rewrites65.5%
Applied rewrites62.7%
Applied rewrites65.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6464.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6464.6%
Applied rewrites64.6%
herbie shell --seed 2025277 -o generate:taylor -o generate:evaluate
(FPCore (z0 z1 z2 z3)
:name "(sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3))"
:precision binary64
(sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3)))