
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (fma (sin y) (- z) (+ x (cos y))))
double code(double x, double y, double z) {
return fma(sin(y), -z, (x + cos(y)));
}
function code(x, y, z) return fma(sin(y), Float64(-z), Float64(x + cos(y))) end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * (-z) + N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin y, -z, x + \cos y\right)
\end{array}
Initial program 99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
*-commutative99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x -100000000.0) (+ x 1.0) (if (<= x 190000000.0) (- (cos y) (* (sin y) z)) (+ x (cos y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -100000000.0) {
tmp = x + 1.0;
} else if (x <= 190000000.0) {
tmp = cos(y) - (sin(y) * z);
} else {
tmp = x + cos(y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-100000000.0d0)) then
tmp = x + 1.0d0
else if (x <= 190000000.0d0) then
tmp = cos(y) - (sin(y) * z)
else
tmp = x + cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -100000000.0) {
tmp = x + 1.0;
} else if (x <= 190000000.0) {
tmp = Math.cos(y) - (Math.sin(y) * z);
} else {
tmp = x + Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -100000000.0: tmp = x + 1.0 elif x <= 190000000.0: tmp = math.cos(y) - (math.sin(y) * z) else: tmp = x + math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -100000000.0) tmp = Float64(x + 1.0); elseif (x <= 190000000.0) tmp = Float64(cos(y) - Float64(sin(y) * z)); else tmp = Float64(x + cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -100000000.0) tmp = x + 1.0; elseif (x <= 190000000.0) tmp = cos(y) - (sin(y) * z); else tmp = x + cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -100000000.0], N[(x + 1.0), $MachinePrecision], If[LessEqual[x, 190000000.0], N[(N[Cos[y], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -100000000:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;x \leq 190000000:\\
\;\;\;\;\cos y - \sin y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \cos y\\
\end{array}
\end{array}
if x < -1e8Initial program 99.9%
Taylor expanded in y around 0 89.3%
+-commutative89.3%
Simplified89.3%
if -1e8 < x < 1.9e8Initial program 99.9%
Taylor expanded in x around 0 97.6%
if 1.9e8 < x Initial program 99.9%
Taylor expanded in z around 0 85.7%
Final simplification93.1%
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* (sin y) z)))
double code(double x, double y, double z) {
return (x + cos(y)) - (sin(y) * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + cos(y)) - (sin(y) * z)
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (Math.sin(y) * z);
}
def code(x, y, z): return (x + math.cos(y)) - (math.sin(y) * z)
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(sin(y) * z)) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (sin(y) * z); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - \sin y \cdot z
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e+141) (not (<= z 8e+167))) (* z (- (sin y))) (+ x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+141) || !(z <= 8e+167)) {
tmp = z * -sin(y);
} else {
tmp = x + cos(y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1d+141)) .or. (.not. (z <= 8d+167))) then
tmp = z * -sin(y)
else
tmp = x + cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+141) || !(z <= 8e+167)) {
tmp = z * -Math.sin(y);
} else {
tmp = x + Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e+141) or not (z <= 8e+167): tmp = z * -math.sin(y) else: tmp = x + math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e+141) || !(z <= 8e+167)) tmp = Float64(z * Float64(-sin(y))); else tmp = Float64(x + cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e+141) || ~((z <= 8e+167))) tmp = z * -sin(y); else tmp = x + cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e+141], N[Not[LessEqual[z, 8e+167]], $MachinePrecision]], N[(z * (-N[Sin[y], $MachinePrecision])), $MachinePrecision], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+141} \lor \neg \left(z \leq 8 \cdot 10^{+167}\right):\\
\;\;\;\;z \cdot \left(-\sin y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \cos y\\
\end{array}
\end{array}
if z < -1.00000000000000002e141 or 8.0000000000000003e167 < z Initial program 99.8%
Taylor expanded in z around inf 71.0%
neg-mul-171.0%
distribute-rgt-neg-in71.0%
Simplified71.0%
if -1.00000000000000002e141 < z < 8.0000000000000003e167Initial program 100.0%
Taylor expanded in z around 0 89.9%
Final simplification83.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.0008) (not (<= y 8.5e+16))) (+ x (cos y)) (+ 1.0 (- x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0008) || !(y <= 8.5e+16)) {
tmp = x + cos(y);
} else {
tmp = 1.0 + (x - (y * z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-0.0008d0)) .or. (.not. (y <= 8.5d+16))) then
tmp = x + cos(y)
else
tmp = 1.0d0 + (x - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0008) || !(y <= 8.5e+16)) {
tmp = x + Math.cos(y);
} else {
tmp = 1.0 + (x - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.0008) or not (y <= 8.5e+16): tmp = x + math.cos(y) else: tmp = 1.0 + (x - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.0008) || !(y <= 8.5e+16)) tmp = Float64(x + cos(y)); else tmp = Float64(1.0 + Float64(x - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.0008) || ~((y <= 8.5e+16))) tmp = x + cos(y); else tmp = 1.0 + (x - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.0008], N[Not[LessEqual[y, 8.5e+16]], $MachinePrecision]], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0008 \lor \neg \left(y \leq 8.5 \cdot 10^{+16}\right):\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x - y \cdot z\right)\\
\end{array}
\end{array}
if y < -8.00000000000000038e-4 or 8.5e16 < y Initial program 99.8%
Taylor expanded in z around 0 60.3%
if -8.00000000000000038e-4 < y < 8.5e16Initial program 100.0%
Taylor expanded in y around 0 98.6%
+-commutative98.6%
mul-1-neg98.6%
unsub-neg98.6%
*-commutative98.6%
Applied egg-rr98.6%
Final simplification80.6%
(FPCore (x y z)
:precision binary64
(if (<= y -5.8e+219)
(cos y)
(if (<= y -9.2e+82)
(+ x 1.0)
(if (<= y 8.5e+16) (+ 1.0 (- x (* y z))) (+ x 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+219) {
tmp = cos(y);
} else if (y <= -9.2e+82) {
tmp = x + 1.0;
} else if (y <= 8.5e+16) {
tmp = 1.0 + (x - (y * z));
} else {
tmp = x + 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5.8d+219)) then
tmp = cos(y)
else if (y <= (-9.2d+82)) then
tmp = x + 1.0d0
else if (y <= 8.5d+16) then
tmp = 1.0d0 + (x - (y * z))
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+219) {
tmp = Math.cos(y);
} else if (y <= -9.2e+82) {
tmp = x + 1.0;
} else if (y <= 8.5e+16) {
tmp = 1.0 + (x - (y * z));
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.8e+219: tmp = math.cos(y) elif y <= -9.2e+82: tmp = x + 1.0 elif y <= 8.5e+16: tmp = 1.0 + (x - (y * z)) else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.8e+219) tmp = cos(y); elseif (y <= -9.2e+82) tmp = Float64(x + 1.0); elseif (y <= 8.5e+16) tmp = Float64(1.0 + Float64(x - Float64(y * z))); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.8e+219) tmp = cos(y); elseif (y <= -9.2e+82) tmp = x + 1.0; elseif (y <= 8.5e+16) tmp = 1.0 + (x - (y * z)); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.8e+219], N[Cos[y], $MachinePrecision], If[LessEqual[y, -9.2e+82], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 8.5e+16], N[(1.0 + N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+219}:\\
\;\;\;\;\cos y\\
\mathbf{elif}\;y \leq -9.2 \cdot 10^{+82}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+16}:\\
\;\;\;\;1 + \left(x - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -5.79999999999999958e219Initial program 99.8%
Taylor expanded in x around 0 94.0%
Taylor expanded in z around 0 39.0%
if -5.79999999999999958e219 < y < -9.19999999999999953e82 or 8.5e16 < y Initial program 99.8%
Taylor expanded in y around 0 44.0%
+-commutative44.0%
Simplified44.0%
if -9.19999999999999953e82 < y < 8.5e16Initial program 100.0%
Taylor expanded in y around 0 95.0%
+-commutative95.0%
mul-1-neg95.0%
unsub-neg95.0%
*-commutative95.0%
Applied egg-rr95.0%
Final simplification72.6%
(FPCore (x y z) :precision binary64 (if (<= y -3.9e+85) (+ x 1.0) (if (<= y 2.1e+17) (+ 1.0 (- x (* y z))) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.9e+85) {
tmp = x + 1.0;
} else if (y <= 2.1e+17) {
tmp = 1.0 + (x - (y * z));
} else {
tmp = x + 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-3.9d+85)) then
tmp = x + 1.0d0
else if (y <= 2.1d+17) then
tmp = 1.0d0 + (x - (y * z))
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.9e+85) {
tmp = x + 1.0;
} else if (y <= 2.1e+17) {
tmp = 1.0 + (x - (y * z));
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.9e+85: tmp = x + 1.0 elif y <= 2.1e+17: tmp = 1.0 + (x - (y * z)) else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.9e+85) tmp = Float64(x + 1.0); elseif (y <= 2.1e+17) tmp = Float64(1.0 + Float64(x - Float64(y * z))); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.9e+85) tmp = x + 1.0; elseif (y <= 2.1e+17) tmp = 1.0 + (x - (y * z)); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.9e+85], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 2.1e+17], N[(1.0 + N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{+85}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+17}:\\
\;\;\;\;1 + \left(x - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -3.90000000000000033e85 or 2.1e17 < y Initial program 99.8%
Taylor expanded in y around 0 38.9%
+-commutative38.9%
Simplified38.9%
if -3.90000000000000033e85 < y < 2.1e17Initial program 100.0%
Taylor expanded in y around 0 95.0%
+-commutative95.0%
mul-1-neg95.0%
unsub-neg95.0%
*-commutative95.0%
Applied egg-rr95.0%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (if (<= x -2.3e-6) (+ x 1.0) (if (<= x 9.6e-13) (- 1.0 (* y z)) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.3e-6) {
tmp = x + 1.0;
} else if (x <= 9.6e-13) {
tmp = 1.0 - (y * z);
} else {
tmp = x + 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-2.3d-6)) then
tmp = x + 1.0d0
else if (x <= 9.6d-13) then
tmp = 1.0d0 - (y * z)
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.3e-6) {
tmp = x + 1.0;
} else if (x <= 9.6e-13) {
tmp = 1.0 - (y * z);
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.3e-6: tmp = x + 1.0 elif x <= 9.6e-13: tmp = 1.0 - (y * z) else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.3e-6) tmp = Float64(x + 1.0); elseif (x <= 9.6e-13) tmp = Float64(1.0 - Float64(y * z)); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.3e-6) tmp = x + 1.0; elseif (x <= 9.6e-13) tmp = 1.0 - (y * z); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.3e-6], N[(x + 1.0), $MachinePrecision], If[LessEqual[x, 9.6e-13], N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{-6}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;x \leq 9.6 \cdot 10^{-13}:\\
\;\;\;\;1 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if x < -2.3e-6 or 9.5999999999999995e-13 < x Initial program 99.9%
Taylor expanded in y around 0 83.9%
+-commutative83.9%
Simplified83.9%
if -2.3e-6 < x < 9.5999999999999995e-13Initial program 99.9%
Taylor expanded in y around 0 53.8%
Taylor expanded in y around inf 53.5%
mul-1-neg53.5%
distribute-rgt-neg-in53.5%
Simplified53.5%
Taylor expanded in y around 0 53.5%
mul-1-neg53.5%
sub-neg53.5%
Simplified53.5%
Final simplification68.6%
(FPCore (x y z) :precision binary64 (if (<= z 2e+259) (+ x 1.0) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2e+259) {
tmp = x + 1.0;
} else {
tmp = y * -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 2d+259) then
tmp = x + 1.0d0
else
tmp = y * -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2e+259) {
tmp = x + 1.0;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2e+259: tmp = x + 1.0 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2e+259) tmp = Float64(x + 1.0); else tmp = Float64(y * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2e+259) tmp = x + 1.0; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2e+259], N[(x + 1.0), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2 \cdot 10^{+259}:\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 2e259Initial program 99.9%
Taylor expanded in y around 0 62.0%
+-commutative62.0%
Simplified62.0%
if 2e259 < z Initial program 100.0%
Taylor expanded in y around 0 78.8%
Taylor expanded in y around inf 78.8%
mul-1-neg78.8%
distribute-rgt-neg-in78.8%
Simplified78.8%
Taylor expanded in y around inf 73.1%
mul-1-neg73.1%
distribute-rgt-neg-in73.1%
Simplified73.1%
Final simplification62.4%
(FPCore (x y z) :precision binary64 (if (<= x -1.35e-6) x (if (<= x 1.0) 1.0 x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.35e-6) {
tmp = x;
} else if (x <= 1.0) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.35d-6)) then
tmp = x
else if (x <= 1.0d0) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.35e-6) {
tmp = x;
} else if (x <= 1.0) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.35e-6: tmp = x elif x <= 1.0: tmp = 1.0 else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.35e-6) tmp = x; elseif (x <= 1.0) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.35e-6) tmp = x; elseif (x <= 1.0) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.35e-6], x, If[LessEqual[x, 1.0], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.34999999999999999e-6 or 1 < x Initial program 99.9%
Taylor expanded in x around inf 83.1%
if -1.34999999999999999e-6 < x < 1Initial program 99.9%
Taylor expanded in y around 0 54.2%
Taylor expanded in y around inf 52.5%
mul-1-neg52.5%
distribute-rgt-neg-in52.5%
Simplified52.5%
Taylor expanded in y around 0 36.4%
Final simplification58.6%
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
return x + 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + 1.0d0
end function
public static double code(double x, double y, double z) {
return x + 1.0;
}
def code(x, y, z): return x + 1.0
function code(x, y, z) return Float64(x + 1.0) end
function tmp = code(x, y, z) tmp = x + 1.0; end
code[x_, y_, z_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 59.9%
+-commutative59.9%
Simplified59.9%
Final simplification59.9%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 63.1%
Taylor expanded in y around inf 30.3%
mul-1-neg30.3%
distribute-rgt-neg-in30.3%
Simplified30.3%
Taylor expanded in y around 0 20.4%
Final simplification20.4%
herbie shell --seed 2023274
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))