
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 3.8e+33)
(/ x (* (/ z_m (sin y)) y))
(/ (* x (/ (sin y) y)) z_m))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 3.8e+33) {
tmp = x / ((z_m / sin(y)) * y);
} else {
tmp = (x * (sin(y) / y)) / z_m;
}
return z_s * tmp;
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 3.8d+33) then
tmp = x / ((z_m / sin(y)) * y)
else
tmp = (x * (sin(y) / y)) / z_m
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 3.8e+33) {
tmp = x / ((z_m / Math.sin(y)) * y);
} else {
tmp = (x * (Math.sin(y) / y)) / z_m;
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if z_m <= 3.8e+33: tmp = x / ((z_m / math.sin(y)) * y) else: tmp = (x * (math.sin(y) / y)) / z_m return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 3.8e+33) tmp = Float64(x / Float64(Float64(z_m / sin(y)) * y)); else tmp = Float64(Float64(x * Float64(sin(y) / y)) / z_m); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (z_m <= 3.8e+33) tmp = x / ((z_m / sin(y)) * y); else tmp = (x * (sin(y) / y)) / z_m; end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 3.8e+33], N[(x / N[(N[(z$95$m / N[Sin[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 3.8 \cdot 10^{+33}:\\
\;\;\;\;\frac{x}{\frac{z\_m}{\sin y} \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z\_m}\\
\end{array}
\end{array}
if z < 3.80000000000000002e33Initial program 96.0%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6495.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.4
Applied rewrites95.4%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-flip-revN/A
lower-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f6488.4
Applied rewrites88.4%
if 3.80000000000000002e33 < z Initial program 96.0%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= y 0.0003)
(/ (fma (* -0.16666666666666666 (* y y)) x x) z_m)
(* (/ (/ (sin y) z_m) y) x))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.0003) {
tmp = fma((-0.16666666666666666 * (y * y)), x, x) / z_m;
} else {
tmp = ((sin(y) / z_m) / y) * x;
}
return z_s * tmp;
}
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 0.0003) tmp = Float64(fma(Float64(-0.16666666666666666 * Float64(y * y)), x, x) / z_m); else tmp = Float64(Float64(Float64(sin(y) / z_m) / y) * x); end return Float64(z_s * tmp) end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 0.0003], N[(N[(N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision] / z$95$m), $MachinePrecision], N[(N[(N[(N[Sin[y], $MachinePrecision] / z$95$m), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 0.0003:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.16666666666666666 \cdot \left(y \cdot y\right), x, x\right)}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sin y}{z\_m}}{y} \cdot x\\
\end{array}
\end{array}
if y < 2.99999999999999974e-4Initial program 96.0%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6451.2
Applied rewrites51.2%
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-fma.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
associate-*l/N/A
associate-*l/N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6453.4
Applied rewrites53.4%
if 2.99999999999999974e-4 < y Initial program 96.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.1
Applied rewrites89.1%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= y 0.0003)
(/ (fma (* -0.16666666666666666 (* y y)) x x) z_m)
(* (/ (sin y) (* z_m y)) x))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.0003) {
tmp = fma((-0.16666666666666666 * (y * y)), x, x) / z_m;
} else {
tmp = (sin(y) / (z_m * y)) * x;
}
return z_s * tmp;
}
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 0.0003) tmp = Float64(fma(Float64(-0.16666666666666666 * Float64(y * y)), x, x) / z_m); else tmp = Float64(Float64(sin(y) / Float64(z_m * y)) * x); end return Float64(z_s * tmp) end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 0.0003], N[(N[(N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision] / z$95$m), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 0.0003:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.16666666666666666 \cdot \left(y \cdot y\right), x, x\right)}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{z\_m \cdot y} \cdot x\\
\end{array}
\end{array}
if y < 2.99999999999999974e-4Initial program 96.0%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6451.2
Applied rewrites51.2%
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-fma.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
associate-*l/N/A
associate-*l/N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6453.4
Applied rewrites53.4%
if 2.99999999999999974e-4 < y Initial program 96.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= y 0.00055)
(/ (fma (* -0.16666666666666666 (* y y)) x x) z_m)
(* (/ x (* z_m y)) (sin y)))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.00055) {
tmp = fma((-0.16666666666666666 * (y * y)), x, x) / z_m;
} else {
tmp = (x / (z_m * y)) * sin(y);
}
return z_s * tmp;
}
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 0.00055) tmp = Float64(fma(Float64(-0.16666666666666666 * Float64(y * y)), x, x) / z_m); else tmp = Float64(Float64(x / Float64(z_m * y)) * sin(y)); end return Float64(z_s * tmp) end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 0.00055], N[(N[(N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision] / z$95$m), $MachinePrecision], N[(N[(x / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 0.00055:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.16666666666666666 \cdot \left(y \cdot y\right), x, x\right)}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z\_m \cdot y} \cdot \sin y\\
\end{array}
\end{array}
if y < 5.50000000000000033e-4Initial program 96.0%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6451.2
Applied rewrites51.2%
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-fma.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
associate-*l/N/A
associate-*l/N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6453.4
Applied rewrites53.4%
if 5.50000000000000033e-4 < y Initial program 96.0%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
*-commutativeN/A
mult-flip-revN/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6483.6
Applied rewrites83.6%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= (/ (* x (/ (sin y) y)) z_m) -5e-30)
(/
1.0
(*
(/ 1.0 (/ 1.0 z_m))
(/ (/ 1.0 x) (fma (* -0.16666666666666666 y) y 1.0))))
(/ 1.0 (fma 0.16666666666666666 (/ (* (pow y 2.0) z_m) x) (/ z_m x))))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (((x * (sin(y) / y)) / z_m) <= -5e-30) {
tmp = 1.0 / ((1.0 / (1.0 / z_m)) * ((1.0 / x) / fma((-0.16666666666666666 * y), y, 1.0)));
} else {
tmp = 1.0 / fma(0.16666666666666666, ((pow(y, 2.0) * z_m) / x), (z_m / x));
}
return z_s * tmp;
}
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (Float64(Float64(x * Float64(sin(y) / y)) / z_m) <= -5e-30) tmp = Float64(1.0 / Float64(Float64(1.0 / Float64(1.0 / z_m)) * Float64(Float64(1.0 / x) / fma(Float64(-0.16666666666666666 * y), y, 1.0)))); else tmp = Float64(1.0 / fma(0.16666666666666666, Float64(Float64((y ^ 2.0) * z_m) / x), Float64(z_m / x))); end return Float64(z_s * tmp) end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], -5e-30], N[(1.0 / N[(N[(1.0 / N[(1.0 / z$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(N[(-0.16666666666666666 * y), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(0.16666666666666666 * N[(N[(N[Power[y, 2.0], $MachinePrecision] * z$95$m), $MachinePrecision] / x), $MachinePrecision] + N[(z$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{x \cdot \frac{\sin y}{y}}{z\_m} \leq -5 \cdot 10^{-30}:\\
\;\;\;\;\frac{1}{\frac{1}{\frac{1}{z\_m}} \cdot \frac{\frac{1}{x}}{\mathsf{fma}\left(-0.16666666666666666 \cdot y, y, 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.16666666666666666, \frac{{y}^{2} \cdot z\_m}{x}, \frac{z\_m}{x}\right)}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) < -4.99999999999999972e-30Initial program 96.0%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6451.2
Applied rewrites51.2%
lift-fma.f64N/A
lift-/.f64N/A
add-to-fractionN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.9
lift-pow.f64N/A
unpow2N/A
lower-*.f6451.9
Applied rewrites51.9%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f32N/A
lower-/.f32N/A
div-flip-revN/A
lift-/.f64N/A
lift-/.f64N/A
lower-unsound-/.f6451.9
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-fma.f64N/A
add-to-fraction-revN/A
Applied rewrites53.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6452.9
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6452.9
Applied rewrites52.9%
if -4.99999999999999972e-30 < (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) Initial program 96.0%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6495.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.4
Applied rewrites95.4%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6465.8
Applied rewrites65.8%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 2.35e-35)
(/ (fma (* -0.16666666666666666 (* y y)) x x) z_m)
(* (/ y (* z_m y)) x))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 2.35e-35) {
tmp = fma((-0.16666666666666666 * (y * y)), x, x) / z_m;
} else {
tmp = (y / (z_m * y)) * x;
}
return z_s * tmp;
}
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 2.35e-35) tmp = Float64(fma(Float64(-0.16666666666666666 * Float64(y * y)), x, x) / z_m); else tmp = Float64(Float64(y / Float64(z_m * y)) * x); end return Float64(z_s * tmp) end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 2.35e-35], N[(N[(N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision] / z$95$m), $MachinePrecision], N[(N[(y / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.35 \cdot 10^{-35}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.16666666666666666 \cdot \left(y \cdot y\right), x, x\right)}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot y} \cdot x\\
\end{array}
\end{array}
if z < 2.35e-35Initial program 96.0%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6451.2
Applied rewrites51.2%
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-fma.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
associate-*l/N/A
associate-*l/N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6453.4
Applied rewrites53.4%
if 2.35e-35 < z Initial program 96.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Taylor expanded in y around 0
Applied rewrites54.8%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 2.35e-35)
(* (fma (* -0.16666666666666666 y) y 1.0) (/ x z_m))
(* (/ y (* z_m y)) x))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 2.35e-35) {
tmp = fma((-0.16666666666666666 * y), y, 1.0) * (x / z_m);
} else {
tmp = (y / (z_m * y)) * x;
}
return z_s * tmp;
}
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 2.35e-35) tmp = Float64(fma(Float64(-0.16666666666666666 * y), y, 1.0) * Float64(x / z_m)); else tmp = Float64(Float64(y / Float64(z_m * y)) * x); end return Float64(z_s * tmp) end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 2.35e-35], N[(N[(N[(-0.16666666666666666 * y), $MachinePrecision] * y + 1.0), $MachinePrecision] * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.35 \cdot 10^{-35}:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666 \cdot y, y, 1\right) \cdot \frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot y} \cdot x\\
\end{array}
\end{array}
if z < 2.35e-35Initial program 96.0%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6451.2
Applied rewrites51.2%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-add-revN/A
mult-flipN/A
lower-*.f64N/A
+-commutativeN/A
*-rgt-identityN/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6453.2
Applied rewrites53.2%
Applied rewrites55.1%
if 2.35e-35 < z Initial program 96.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Taylor expanded in y around 0
Applied rewrites54.8%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 2.35e-35)
(* (/ (fma -0.16666666666666666 (* y y) 1.0) z_m) x)
(* (/ y (* z_m y)) x))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 2.35e-35) {
tmp = (fma(-0.16666666666666666, (y * y), 1.0) / z_m) * x;
} else {
tmp = (y / (z_m * y)) * x;
}
return z_s * tmp;
}
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 2.35e-35) tmp = Float64(Float64(fma(-0.16666666666666666, Float64(y * y), 1.0) / z_m) * x); else tmp = Float64(Float64(y / Float64(z_m * y)) * x); end return Float64(z_s * tmp) end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 2.35e-35], N[(N[(N[(-0.16666666666666666 * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] / z$95$m), $MachinePrecision] * x), $MachinePrecision], N[(N[(y / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.35 \cdot 10^{-35}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.16666666666666666, y \cdot y, 1\right)}{z\_m} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot y} \cdot x\\
\end{array}
\end{array}
if z < 2.35e-35Initial program 96.0%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f6451.2
Applied rewrites51.2%
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.2
lift-fma.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f6453.2
Applied rewrites53.2%
if 2.35e-35 < z Initial program 96.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Taylor expanded in y around 0
Applied rewrites54.8%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= z_m 8.2e+37) (/ 1.0 (/ z_m x)) (* (/ y (* z_m y)) x))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 8.2e+37) {
tmp = 1.0 / (z_m / x);
} else {
tmp = (y / (z_m * y)) * x;
}
return z_s * tmp;
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 8.2d+37) then
tmp = 1.0d0 / (z_m / x)
else
tmp = (y / (z_m * y)) * x
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 8.2e+37) {
tmp = 1.0 / (z_m / x);
} else {
tmp = (y / (z_m * y)) * x;
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if z_m <= 8.2e+37: tmp = 1.0 / (z_m / x) else: tmp = (y / (z_m * y)) * x return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 8.2e+37) tmp = Float64(1.0 / Float64(z_m / x)); else tmp = Float64(Float64(y / Float64(z_m * y)) * x); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (z_m <= 8.2e+37) tmp = 1.0 / (z_m / x); else tmp = (y / (z_m * y)) * x; end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 8.2e+37], N[(1.0 / N[(z$95$m / x), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 8.2 \cdot 10^{+37}:\\
\;\;\;\;\frac{1}{\frac{z\_m}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot y} \cdot x\\
\end{array}
\end{array}
if z < 8.1999999999999996e37Initial program 96.0%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6495.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.4
Applied rewrites95.4%
Taylor expanded in y around 0
lower-/.f6458.5
Applied rewrites58.5%
if 8.1999999999999996e37 < z Initial program 96.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Taylor expanded in y around 0
Applied rewrites54.8%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (/ x z_m)))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
return z_s * (x / z_m);
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = z_s * (x / z_m)
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
return z_s * (x / z_m);
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): return z_s * (x / z_m)
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) return Float64(z_s * Float64(x / z_m)) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m) tmp = z_s * (x / z_m); end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \frac{x}{z\_m}
\end{array}
Initial program 96.0%
Taylor expanded in y around 0
lower-/.f6458.7
Applied rewrites58.7%
herbie shell --seed 2025154
(FPCore (x y z)
:name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
:precision binary64
(/ (* x (/ (sin y) y)) z))