
(FPCore (z0 z1 z2 z3 z4 z5) :precision binary64 (sqrt (* (* (+ z0 z0) z1) (- (- z2 (* (/ z3 z4) (+ z3 z3))) (* (* z0 (* (/ z3 z4) (/ z3 z4))) (- z1 z5))))))
double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))));
}
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, z4, z5)
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), intent (in) :: z4
real(8), intent (in) :: z5
code = sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))))
end function
public static double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return Math.sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))));
}
def code(z0, z1, z2, z3, z4, z5): return math.sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))))
function code(z0, z1, z2, z3, z4, z5) return sqrt(Float64(Float64(Float64(z0 + z0) * z1) * Float64(Float64(z2 - Float64(Float64(z3 / z4) * Float64(z3 + z3))) - Float64(Float64(z0 * Float64(Float64(z3 / z4) * Float64(z3 / z4))) * Float64(z1 - z5))))) end
function tmp = code(z0, z1, z2, z3, z4, z5) tmp = sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5))))); end
code[z0_, z1_, z2_, z3_, z4_, z5_] := N[Sqrt[N[(N[(N[(z0 + z0), $MachinePrecision] * z1), $MachinePrecision] * N[(N[(z2 - N[(N[(z3 / z4), $MachinePrecision] * N[(z3 + z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(z0 * N[(N[(z3 / z4), $MachinePrecision] * N[(z3 / z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z1 - z5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(z0 + z0\right) \cdot z1\right) \cdot \left(\left(z2 - \frac{z3}{z4} \cdot \left(z3 + z3\right)\right) - \left(z0 \cdot \left(\frac{z3}{z4} \cdot \frac{z3}{z4}\right)\right) \cdot \left(z1 - z5\right)\right)}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0 z1 z2 z3 z4 z5) :precision binary64 (sqrt (* (* (+ z0 z0) z1) (- (- z2 (* (/ z3 z4) (+ z3 z3))) (* (* z0 (* (/ z3 z4) (/ z3 z4))) (- z1 z5))))))
double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))));
}
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, z4, z5)
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), intent (in) :: z4
real(8), intent (in) :: z5
code = sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))))
end function
public static double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return Math.sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))));
}
def code(z0, z1, z2, z3, z4, z5): return math.sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))))
function code(z0, z1, z2, z3, z4, z5) return sqrt(Float64(Float64(Float64(z0 + z0) * z1) * Float64(Float64(z2 - Float64(Float64(z3 / z4) * Float64(z3 + z3))) - Float64(Float64(z0 * Float64(Float64(z3 / z4) * Float64(z3 / z4))) * Float64(z1 - z5))))) end
function tmp = code(z0, z1, z2, z3, z4, z5) tmp = sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5))))); end
code[z0_, z1_, z2_, z3_, z4_, z5_] := N[Sqrt[N[(N[(N[(z0 + z0), $MachinePrecision] * z1), $MachinePrecision] * N[(N[(z2 - N[(N[(z3 / z4), $MachinePrecision] * N[(z3 + z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(z0 * N[(N[(z3 / z4), $MachinePrecision] * N[(z3 / z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z1 - z5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(z0 + z0\right) \cdot z1\right) \cdot \left(\left(z2 - \frac{z3}{z4} \cdot \left(z3 + z3\right)\right) - \left(z0 \cdot \left(\frac{z3}{z4} \cdot \frac{z3}{z4}\right)\right) \cdot \left(z1 - z5\right)\right)}
(FPCore (z0 z1 z2 z3 z4 z5)
:precision binary64
(let* ((t_0 (* (/ z3 z4) z0)))
(if (<=
(*
(* (+ z0 z0) z1)
(-
(- z2 (* (/ z3 z4) (+ z3 z3)))
(* (* z0 (* (/ z3 z4) (/ z3 z4))) (- z1 z5))))
1000000000000000017652801462756379714374878780719864776839443139119744823869255243069012222883470359078822072829219411228534934402712624705615450492327979456500795456339201761949451160807447294527656222743617592048849967890105831362861792425329827928397252374398383022243308510390698430058459037696)
(sqrt
(304-z0z1z2z3z4
(- z2 (* (/ z3 z4) (- (+ z3 z3) (* (- z5 z1) t_0))))
z1
z0
(- z1)
z0))
(sqrt
(*
(*
(- z2 (* (/ z3 z4) (+ (+ (* t_0 (- z1 z5)) z3) z3)))
(+ z0 z0))
z1)))))\begin{array}{l}
t_0 := \frac{z3}{z4} \cdot z0\\
\mathbf{if}\;\left(\left(z0 + z0\right) \cdot z1\right) \cdot \left(\left(z2 - \frac{z3}{z4} \cdot \left(z3 + z3\right)\right) - \left(z0 \cdot \left(\frac{z3}{z4} \cdot \frac{z3}{z4}\right)\right) \cdot \left(z1 - z5\right)\right) \leq 1000000000000000017652801462756379714374878780719864776839443139119744823869255243069012222883470359078822072829219411228534934402712624705615450492327979456500795456339201761949451160807447294527656222743617592048849967890105831362861792425329827928397252374398383022243308510390698430058459037696:\\
\;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(\left(z2 - \frac{z3}{z4} \cdot \left(\left(z3 + z3\right) - \left(z5 - z1\right) \cdot t\_0\right)\right), z1, z0, \left(-z1\right), z0\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(z2 - \frac{z3}{z4} \cdot \left(\left(t\_0 \cdot \left(z1 - z5\right) + z3\right) + z3\right)\right) \cdot \left(z0 + z0\right)\right) \cdot z1}\\
\end{array}
if (*.f64 (*.f64 (+.f64 z0 z0) z1) (-.f64 (-.f64 z2 (*.f64 (/.f64 z3 z4) (+.f64 z3 z3))) (*.f64 (*.f64 z0 (*.f64 (/.f64 z3 z4) (/.f64 z3 z4))) (-.f64 z1 z5)))) < 1e297Initial program 53.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
lower-304-z0z1z2z3z4N/A
Applied rewrites48.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
if 1e297 < (*.f64 (*.f64 (+.f64 z0 z0) z1) (-.f64 (-.f64 z2 (*.f64 (/.f64 z3 z4) (+.f64 z3 z3))) (*.f64 (*.f64 z0 (*.f64 (/.f64 z3 z4) (/.f64 z3 z4))) (-.f64 z1 z5)))) Initial program 53.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites55.8%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f6455.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6459.5%
Applied rewrites59.5%
(FPCore (z0 z1 z2 z3 z4 z5)
:precision binary64
(let* ((t_0
(sqrt
(*
(* (+ z0 z0) z1)
(-
(- z2 (* (/ z3 z4) (+ z3 z3)))
(* (* z0 (* (/ z3 z4) (/ z3 z4))) (- z1 z5))))))
(t_1
(sqrt
(*
(*
(-
z2
(*
(/ z3 z4)
(+ (+ (* (* (/ z3 z4) z0) (- z1 z5)) z3) z3)))
(+ z0 z0))
z1))))
(if (<= t_0 1000000000000000)
t_1
(if (<=
t_0
199999999999999982405111001914463627825705729939051460364922737117355163153802565541919878198424069508213948681199740222346696327168)
(sqrt
(*
(-
z2
(* (/ z3 z4) (+ (* (* (- z1 z5) z0) (/ z3 z4)) (+ z3 z3))))
(* z1 (+ z0 z0))))
t_1))))double code(double z0, double z1, double z2, double z3, double z4, double z5) {
double t_0 = sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))));
double t_1 = sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1));
double tmp;
if (t_0 <= 1e+15) {
tmp = t_1;
} else if (t_0 <= 2e+131) {
tmp = sqrt(((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z1 * (z0 + z0))));
} 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, z4, z5)
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), intent (in) :: z4
real(8), intent (in) :: z5
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))))
t_1 = sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1))
if (t_0 <= 1d+15) then
tmp = t_1
else if (t_0 <= 2d+131) then
tmp = sqrt(((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z1 * (z0 + z0))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double z0, double z1, double z2, double z3, double z4, double z5) {
double t_0 = Math.sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5)))));
double t_1 = Math.sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1));
double tmp;
if (t_0 <= 1e+15) {
tmp = t_1;
} else if (t_0 <= 2e+131) {
tmp = Math.sqrt(((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z1 * (z0 + z0))));
} else {
tmp = t_1;
}
return tmp;
}
def code(z0, z1, z2, z3, z4, z5): t_0 = math.sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5))))) t_1 = math.sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1)) tmp = 0 if t_0 <= 1e+15: tmp = t_1 elif t_0 <= 2e+131: tmp = math.sqrt(((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z1 * (z0 + z0)))) else: tmp = t_1 return tmp
function code(z0, z1, z2, z3, z4, z5) t_0 = sqrt(Float64(Float64(Float64(z0 + z0) * z1) * Float64(Float64(z2 - Float64(Float64(z3 / z4) * Float64(z3 + z3))) - Float64(Float64(z0 * Float64(Float64(z3 / z4) * Float64(z3 / z4))) * Float64(z1 - z5))))) t_1 = sqrt(Float64(Float64(Float64(z2 - Float64(Float64(z3 / z4) * Float64(Float64(Float64(Float64(Float64(z3 / z4) * z0) * Float64(z1 - z5)) + z3) + z3))) * Float64(z0 + z0)) * z1)) tmp = 0.0 if (t_0 <= 1e+15) tmp = t_1; elseif (t_0 <= 2e+131) tmp = sqrt(Float64(Float64(z2 - Float64(Float64(z3 / z4) * Float64(Float64(Float64(Float64(z1 - z5) * z0) * Float64(z3 / z4)) + Float64(z3 + z3)))) * Float64(z1 * Float64(z0 + z0)))); else tmp = t_1; end return tmp end
function tmp_2 = code(z0, z1, z2, z3, z4, z5) t_0 = sqrt((((z0 + z0) * z1) * ((z2 - ((z3 / z4) * (z3 + z3))) - ((z0 * ((z3 / z4) * (z3 / z4))) * (z1 - z5))))); t_1 = sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1)); tmp = 0.0; if (t_0 <= 1e+15) tmp = t_1; elseif (t_0 <= 2e+131) tmp = sqrt(((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z1 * (z0 + z0)))); else tmp = t_1; end tmp_2 = tmp; end
code[z0_, z1_, z2_, z3_, z4_, z5_] := Block[{t$95$0 = N[Sqrt[N[(N[(N[(z0 + z0), $MachinePrecision] * z1), $MachinePrecision] * N[(N[(z2 - N[(N[(z3 / z4), $MachinePrecision] * N[(z3 + z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(z0 * N[(N[(z3 / z4), $MachinePrecision] * N[(z3 / z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z1 - z5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(N[(z2 - N[(N[(z3 / z4), $MachinePrecision] * N[(N[(N[(N[(N[(z3 / z4), $MachinePrecision] * z0), $MachinePrecision] * N[(z1 - z5), $MachinePrecision]), $MachinePrecision] + z3), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 1000000000000000], t$95$1, If[LessEqual[t$95$0, 199999999999999982405111001914463627825705729939051460364922737117355163153802565541919878198424069508213948681199740222346696327168], N[Sqrt[N[(N[(z2 - N[(N[(z3 / z4), $MachinePrecision] * N[(N[(N[(N[(z1 - z5), $MachinePrecision] * z0), $MachinePrecision] * N[(z3 / z4), $MachinePrecision]), $MachinePrecision] + N[(z3 + z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z1 * N[(z0 + z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sqrt{\left(\left(z0 + z0\right) \cdot z1\right) \cdot \left(\left(z2 - \frac{z3}{z4} \cdot \left(z3 + z3\right)\right) - \left(z0 \cdot \left(\frac{z3}{z4} \cdot \frac{z3}{z4}\right)\right) \cdot \left(z1 - z5\right)\right)}\\
t_1 := \sqrt{\left(\left(z2 - \frac{z3}{z4} \cdot \left(\left(\left(\frac{z3}{z4} \cdot z0\right) \cdot \left(z1 - z5\right) + z3\right) + z3\right)\right) \cdot \left(z0 + z0\right)\right) \cdot z1}\\
\mathbf{if}\;t\_0 \leq 1000000000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 199999999999999982405111001914463627825705729939051460364922737117355163153802565541919878198424069508213948681199740222346696327168:\\
\;\;\;\;\sqrt{\left(z2 - \frac{z3}{z4} \cdot \left(\left(\left(z1 - z5\right) \cdot z0\right) \cdot \frac{z3}{z4} + \left(z3 + z3\right)\right)\right) \cdot \left(z1 \cdot \left(z0 + z0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (sqrt.f64 (*.f64 (*.f64 (+.f64 z0 z0) z1) (-.f64 (-.f64 z2 (*.f64 (/.f64 z3 z4) (+.f64 z3 z3))) (*.f64 (*.f64 z0 (*.f64 (/.f64 z3 z4) (/.f64 z3 z4))) (-.f64 z1 z5))))) < 1e15 or 1.9999999999999998e131 < (sqrt.f64 (*.f64 (*.f64 (+.f64 z0 z0) z1) (-.f64 (-.f64 z2 (*.f64 (/.f64 z3 z4) (+.f64 z3 z3))) (*.f64 (*.f64 z0 (*.f64 (/.f64 z3 z4) (/.f64 z3 z4))) (-.f64 z1 z5))))) Initial program 53.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites55.8%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f6455.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6459.5%
Applied rewrites59.5%
if 1e15 < (sqrt.f64 (*.f64 (*.f64 (+.f64 z0 z0) z1) (-.f64 (-.f64 z2 (*.f64 (/.f64 z3 z4) (+.f64 z3 z3))) (*.f64 (*.f64 z0 (*.f64 (/.f64 z3 z4) (/.f64 z3 z4))) (-.f64 z1 z5))))) < 1.9999999999999998e131Initial program 53.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.4%
Applied rewrites55.5%
(FPCore (z0 z1 z2 z3 z4 z5)
:precision binary64
(if (<=
(sqrt
(*
(* (+ z0 z0) z1)
(-
(- z2 (* (/ z3 z4) (+ z3 z3)))
(* (* z0 (* (/ z3 z4) (/ z3 z4))) (- z1 z5)))))
5000000000000000111755861797384299667549204650486879780239418214450132430121171797988101755921550297505076285418812476851459272474624)
(sqrt
(304-z0z1z2z3z4
(- z2 (* (/ z3 z4) (+ (* (* (- z1 z5) z0) (/ z3 z4)) (+ z3 z3))))
z1
z0
(- z1)
z0))
(sqrt
(*
(*
(- z2 (* (/ z3 z4) (+ (+ (* (* (/ z3 z4) z0) (- z1 z5)) z3) z3)))
(+ z0 z0))
z1))))\begin{array}{l}
\mathbf{if}\;\sqrt{\left(\left(z0 + z0\right) \cdot z1\right) \cdot \left(\left(z2 - \frac{z3}{z4} \cdot \left(z3 + z3\right)\right) - \left(z0 \cdot \left(\frac{z3}{z4} \cdot \frac{z3}{z4}\right)\right) \cdot \left(z1 - z5\right)\right)} \leq 5000000000000000111755861797384299667549204650486879780239418214450132430121171797988101755921550297505076285418812476851459272474624:\\
\;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(\left(z2 - \frac{z3}{z4} \cdot \left(\left(\left(z1 - z5\right) \cdot z0\right) \cdot \frac{z3}{z4} + \left(z3 + z3\right)\right)\right), z1, z0, \left(-z1\right), z0\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(z2 - \frac{z3}{z4} \cdot \left(\left(\left(\frac{z3}{z4} \cdot z0\right) \cdot \left(z1 - z5\right) + z3\right) + z3\right)\right) \cdot \left(z0 + z0\right)\right) \cdot z1}\\
\end{array}
if (sqrt.f64 (*.f64 (*.f64 (+.f64 z0 z0) z1) (-.f64 (-.f64 z2 (*.f64 (/.f64 z3 z4) (+.f64 z3 z3))) (*.f64 (*.f64 z0 (*.f64 (/.f64 z3 z4) (/.f64 z3 z4))) (-.f64 z1 z5))))) < 5.0000000000000001e132Initial program 53.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
lower-304-z0z1z2z3z4N/A
Applied rewrites48.3%
if 5.0000000000000001e132 < (sqrt.f64 (*.f64 (*.f64 (+.f64 z0 z0) z1) (-.f64 (-.f64 z2 (*.f64 (/.f64 z3 z4) (+.f64 z3 z3))) (*.f64 (*.f64 z0 (*.f64 (/.f64 z3 z4) (/.f64 z3 z4))) (-.f64 z1 z5))))) Initial program 53.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites55.8%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f6455.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6459.5%
Applied rewrites59.5%
(FPCore (z0 z1 z2 z3 z4 z5) :precision binary64 (sqrt (* (* (- z2 (* (/ z3 z4) (+ (+ (* (* (/ z3 z4) z0) (- z1 z5)) z3) z3))) (+ z0 z0)) z1)))
double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1));
}
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, z4, z5)
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), intent (in) :: z4
real(8), intent (in) :: z5
code = sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1))
end function
public static double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return Math.sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1));
}
def code(z0, z1, z2, z3, z4, z5): return math.sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1))
function code(z0, z1, z2, z3, z4, z5) return sqrt(Float64(Float64(Float64(z2 - Float64(Float64(z3 / z4) * Float64(Float64(Float64(Float64(Float64(z3 / z4) * z0) * Float64(z1 - z5)) + z3) + z3))) * Float64(z0 + z0)) * z1)) end
function tmp = code(z0, z1, z2, z3, z4, z5) tmp = sqrt((((z2 - ((z3 / z4) * (((((z3 / z4) * z0) * (z1 - z5)) + z3) + z3))) * (z0 + z0)) * z1)); end
code[z0_, z1_, z2_, z3_, z4_, z5_] := N[Sqrt[N[(N[(N[(z2 - N[(N[(z3 / z4), $MachinePrecision] * N[(N[(N[(N[(N[(z3 / z4), $MachinePrecision] * z0), $MachinePrecision] * N[(z1 - z5), $MachinePrecision]), $MachinePrecision] + z3), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z1), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(z2 - \frac{z3}{z4} \cdot \left(\left(\left(\frac{z3}{z4} \cdot z0\right) \cdot \left(z1 - z5\right) + z3\right) + z3\right)\right) \cdot \left(z0 + z0\right)\right) \cdot z1}
Initial program 53.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites55.8%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f6455.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6459.5%
Applied rewrites59.5%
(FPCore (z0 z1 z2 z3 z4 z5)
:precision binary64
(if (<=
z0
-64999999999999996793668510548615010169459801421748008099328347828280602319944494758993776569724065175462201349583033252647656195072525976144106252024887810771477419024973824)
(sqrt
(*
(*
(-
z2
(*
z3
(/ (- (* (+ z3 z3) z4) (* (- z5 z1) (* z3 z0))) (* z4 z4))))
(+ z0 z0))
z1))
(sqrt
(*
(*
(- z2 (* (/ z3 z4) (+ (* (* (- z1 z5) z0) (/ z3 z4)) (+ z3 z3))))
(+ z0 z0))
z1))))double code(double z0, double z1, double z2, double z3, double z4, double z5) {
double tmp;
if (z0 <= -6.5e+172) {
tmp = sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1));
} else {
tmp = sqrt((((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z0 + z0)) * z1));
}
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, z4, z5)
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), intent (in) :: z4
real(8), intent (in) :: z5
real(8) :: tmp
if (z0 <= (-6.5d+172)) then
tmp = sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1))
else
tmp = sqrt((((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z0 + z0)) * z1))
end if
code = tmp
end function
public static double code(double z0, double z1, double z2, double z3, double z4, double z5) {
double tmp;
if (z0 <= -6.5e+172) {
tmp = Math.sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1));
} else {
tmp = Math.sqrt((((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z0 + z0)) * z1));
}
return tmp;
}
def code(z0, z1, z2, z3, z4, z5): tmp = 0 if z0 <= -6.5e+172: tmp = math.sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1)) else: tmp = math.sqrt((((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z0 + z0)) * z1)) return tmp
function code(z0, z1, z2, z3, z4, z5) tmp = 0.0 if (z0 <= -6.5e+172) tmp = sqrt(Float64(Float64(Float64(z2 - Float64(z3 * Float64(Float64(Float64(Float64(z3 + z3) * z4) - Float64(Float64(z5 - z1) * Float64(z3 * z0))) / Float64(z4 * z4)))) * Float64(z0 + z0)) * z1)); else tmp = sqrt(Float64(Float64(Float64(z2 - Float64(Float64(z3 / z4) * Float64(Float64(Float64(Float64(z1 - z5) * z0) * Float64(z3 / z4)) + Float64(z3 + z3)))) * Float64(z0 + z0)) * z1)); end return tmp end
function tmp_2 = code(z0, z1, z2, z3, z4, z5) tmp = 0.0; if (z0 <= -6.5e+172) tmp = sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1)); else tmp = sqrt((((z2 - ((z3 / z4) * ((((z1 - z5) * z0) * (z3 / z4)) + (z3 + z3)))) * (z0 + z0)) * z1)); end tmp_2 = tmp; end
code[z0_, z1_, z2_, z3_, z4_, z5_] := If[LessEqual[z0, -64999999999999996793668510548615010169459801421748008099328347828280602319944494758993776569724065175462201349583033252647656195072525976144106252024887810771477419024973824], N[Sqrt[N[(N[(N[(z2 - N[(z3 * N[(N[(N[(N[(z3 + z3), $MachinePrecision] * z4), $MachinePrecision] - N[(N[(z5 - z1), $MachinePrecision] * N[(z3 * z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z1), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(N[(z2 - N[(N[(z3 / z4), $MachinePrecision] * N[(N[(N[(N[(z1 - z5), $MachinePrecision] * z0), $MachinePrecision] * N[(z3 / z4), $MachinePrecision]), $MachinePrecision] + N[(z3 + z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z1), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z0 \leq -64999999999999996793668510548615010169459801421748008099328347828280602319944494758993776569724065175462201349583033252647656195072525976144106252024887810771477419024973824:\\
\;\;\;\;\sqrt{\left(\left(z2 - z3 \cdot \frac{\left(z3 + z3\right) \cdot z4 - \left(z5 - z1\right) \cdot \left(z3 \cdot z0\right)}{z4 \cdot z4}\right) \cdot \left(z0 + z0\right)\right) \cdot z1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(z2 - \frac{z3}{z4} \cdot \left(\left(\left(z1 - z5\right) \cdot z0\right) \cdot \frac{z3}{z4} + \left(z3 + z3\right)\right)\right) \cdot \left(z0 + z0\right)\right) \cdot z1}\\
\end{array}
if z0 < -6.4999999999999997e172Initial program 53.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites55.8%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
add-to-fractionN/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6441.5%
Applied rewrites41.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.7%
Applied rewrites43.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6446.0%
Applied rewrites46.0%
if -6.4999999999999997e172 < z0 Initial program 53.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites55.8%
(FPCore (z0 z1 z2 z3 z4 z5)
:precision binary64
(sqrt
(*
(*
(-
z2
(* z3 (/ (- (* (+ z3 z3) z4) (* (- z5 z1) (* z3 z0))) (* z4 z4))))
(+ z0 z0))
z1)))double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1));
}
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, z4, z5)
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), intent (in) :: z4
real(8), intent (in) :: z5
code = sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1))
end function
public static double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return Math.sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1));
}
def code(z0, z1, z2, z3, z4, z5): return math.sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1))
function code(z0, z1, z2, z3, z4, z5) return sqrt(Float64(Float64(Float64(z2 - Float64(z3 * Float64(Float64(Float64(Float64(z3 + z3) * z4) - Float64(Float64(z5 - z1) * Float64(z3 * z0))) / Float64(z4 * z4)))) * Float64(z0 + z0)) * z1)) end
function tmp = code(z0, z1, z2, z3, z4, z5) tmp = sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - ((z5 - z1) * (z3 * z0))) / (z4 * z4)))) * (z0 + z0)) * z1)); end
code[z0_, z1_, z2_, z3_, z4_, z5_] := N[Sqrt[N[(N[(N[(z2 - N[(z3 * N[(N[(N[(N[(z3 + z3), $MachinePrecision] * z4), $MachinePrecision] - N[(N[(z5 - z1), $MachinePrecision] * N[(z3 * z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z1), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(z2 - z3 \cdot \frac{\left(z3 + z3\right) \cdot z4 - \left(z5 - z1\right) \cdot \left(z3 \cdot z0\right)}{z4 \cdot z4}\right) \cdot \left(z0 + z0\right)\right) \cdot z1}
Initial program 53.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites55.8%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
add-to-fractionN/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6441.5%
Applied rewrites41.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.7%
Applied rewrites43.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6446.0%
Applied rewrites46.0%
(FPCore (z0 z1 z2 z3 z4 z5)
:precision binary64
(sqrt
(*
(*
(-
z2
(* z3 (/ (- (* (+ z3 z3) z4) (* (* (- z5 z1) z0) z3)) (* z4 z4))))
(+ z0 z0))
z1)))double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - (((z5 - z1) * z0) * z3)) / (z4 * z4)))) * (z0 + z0)) * z1));
}
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, z4, z5)
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), intent (in) :: z4
real(8), intent (in) :: z5
code = sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - (((z5 - z1) * z0) * z3)) / (z4 * z4)))) * (z0 + z0)) * z1))
end function
public static double code(double z0, double z1, double z2, double z3, double z4, double z5) {
return Math.sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - (((z5 - z1) * z0) * z3)) / (z4 * z4)))) * (z0 + z0)) * z1));
}
def code(z0, z1, z2, z3, z4, z5): return math.sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - (((z5 - z1) * z0) * z3)) / (z4 * z4)))) * (z0 + z0)) * z1))
function code(z0, z1, z2, z3, z4, z5) return sqrt(Float64(Float64(Float64(z2 - Float64(z3 * Float64(Float64(Float64(Float64(z3 + z3) * z4) - Float64(Float64(Float64(z5 - z1) * z0) * z3)) / Float64(z4 * z4)))) * Float64(z0 + z0)) * z1)) end
function tmp = code(z0, z1, z2, z3, z4, z5) tmp = sqrt((((z2 - (z3 * ((((z3 + z3) * z4) - (((z5 - z1) * z0) * z3)) / (z4 * z4)))) * (z0 + z0)) * z1)); end
code[z0_, z1_, z2_, z3_, z4_, z5_] := N[Sqrt[N[(N[(N[(z2 - N[(z3 * N[(N[(N[(N[(z3 + z3), $MachinePrecision] * z4), $MachinePrecision] - N[(N[(N[(z5 - z1), $MachinePrecision] * z0), $MachinePrecision] * z3), $MachinePrecision]), $MachinePrecision] / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z1), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(z2 - z3 \cdot \frac{\left(z3 + z3\right) \cdot z4 - \left(\left(z5 - z1\right) \cdot z0\right) \cdot z3}{z4 \cdot z4}\right) \cdot \left(z0 + z0\right)\right) \cdot z1}
Initial program 53.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites55.8%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
add-to-fractionN/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6441.5%
Applied rewrites41.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.7%
Applied rewrites43.7%
herbie shell --seed 2025277 -o generate:taylor -o generate:evaluate
(FPCore (z0 z1 z2 z3 z4 z5)
:name "(sqrt (* (* (+ z0 z0) z1) (- (- z2 (* (/ z3 z4) (+ z3 z3))) (* (* z0 (* (/ z3 z4) (/ z3 z4))) (- z1 z5)))))"
:precision binary64
(sqrt (* (* (+ z0 z0) z1) (- (- z2 (* (/ z3 z4) (+ z3 z3))) (* (* z0 (* (/ z3 z4) (/ z3 z4))) (- z1 z5))))))