
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 + (y * (z - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 + (y * (z - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x (* y (- z x))) z)))
(if (or (<= t_0 -4e+293) (not (<= t_0 2e+300)))
(+ y (* x (- (/ 1.0 z) (/ y z))))
(+ (/ x z) (* y (- 1.0 (/ x z)))))))
double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if ((t_0 <= -4e+293) || !(t_0 <= 2e+300)) {
tmp = y + (x * ((1.0 / z) - (y / z)));
} else {
tmp = (x / z) + (y * (1.0 - (x / 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) :: t_0
real(8) :: tmp
t_0 = (x + (y * (z - x))) / z
if ((t_0 <= (-4d+293)) .or. (.not. (t_0 <= 2d+300))) then
tmp = y + (x * ((1.0d0 / z) - (y / z)))
else
tmp = (x / z) + (y * (1.0d0 - (x / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if ((t_0 <= -4e+293) || !(t_0 <= 2e+300)) {
tmp = y + (x * ((1.0 / z) - (y / z)));
} else {
tmp = (x / z) + (y * (1.0 - (x / z)));
}
return tmp;
}
def code(x, y, z): t_0 = (x + (y * (z - x))) / z tmp = 0 if (t_0 <= -4e+293) or not (t_0 <= 2e+300): tmp = y + (x * ((1.0 / z) - (y / z))) else: tmp = (x / z) + (y * (1.0 - (x / z))) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + Float64(y * Float64(z - x))) / z) tmp = 0.0 if ((t_0 <= -4e+293) || !(t_0 <= 2e+300)) tmp = Float64(y + Float64(x * Float64(Float64(1.0 / z) - Float64(y / z)))); else tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + (y * (z - x))) / z; tmp = 0.0; if ((t_0 <= -4e+293) || ~((t_0 <= 2e+300))) tmp = y + (x * ((1.0 / z) - (y / z))); else tmp = (x / z) + (y * (1.0 - (x / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e+293], N[Not[LessEqual[t$95$0, 2e+300]], $MachinePrecision]], N[(y + N[(x * N[(N[(1.0 / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+293} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+300}\right):\\
\;\;\;\;y + x \cdot \left(\frac{1}{z} - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < -3.9999999999999997e293 or 2.0000000000000001e300 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) Initial program 70.7%
Taylor expanded in x around 0 100.0%
if -3.9999999999999997e293 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 2.0000000000000001e300Initial program 99.9%
Taylor expanded in y around 0 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ y z))))
(if (<= y -1.7e+274)
t_0
(if (<= y -6.3e+174)
(* y (/ (- x) z))
(if (<= y 8.0)
(+ y (/ x z))
(if (or (<= y 1.26e+92) (not (<= y 2.6e+210)))
(/ (* x y) (- z))
t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -1.7e+274) {
tmp = t_0;
} else if (y <= -6.3e+174) {
tmp = y * (-x / z);
} else if (y <= 8.0) {
tmp = y + (x / z);
} else if ((y <= 1.26e+92) || !(y <= 2.6e+210)) {
tmp = (x * y) / -z;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = z * (y / z)
if (y <= (-1.7d+274)) then
tmp = t_0
else if (y <= (-6.3d+174)) then
tmp = y * (-x / z)
else if (y <= 8.0d0) then
tmp = y + (x / z)
else if ((y <= 1.26d+92) .or. (.not. (y <= 2.6d+210))) then
tmp = (x * y) / -z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -1.7e+274) {
tmp = t_0;
} else if (y <= -6.3e+174) {
tmp = y * (-x / z);
} else if (y <= 8.0) {
tmp = y + (x / z);
} else if ((y <= 1.26e+92) || !(y <= 2.6e+210)) {
tmp = (x * y) / -z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) tmp = 0 if y <= -1.7e+274: tmp = t_0 elif y <= -6.3e+174: tmp = y * (-x / z) elif y <= 8.0: tmp = y + (x / z) elif (y <= 1.26e+92) or not (y <= 2.6e+210): tmp = (x * y) / -z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y / z)) tmp = 0.0 if (y <= -1.7e+274) tmp = t_0; elseif (y <= -6.3e+174) tmp = Float64(y * Float64(Float64(-x) / z)); elseif (y <= 8.0) tmp = Float64(y + Float64(x / z)); elseif ((y <= 1.26e+92) || !(y <= 2.6e+210)) tmp = Float64(Float64(x * y) / Float64(-z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y / z); tmp = 0.0; if (y <= -1.7e+274) tmp = t_0; elseif (y <= -6.3e+174) tmp = y * (-x / z); elseif (y <= 8.0) tmp = y + (x / z); elseif ((y <= 1.26e+92) || ~((y <= 2.6e+210))) tmp = (x * y) / -z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e+274], t$95$0, If[LessEqual[y, -6.3e+174], N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.26e+92], N[Not[LessEqual[y, 2.6e+210]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] / (-z)), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+274}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -6.3 \cdot 10^{+174}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\mathbf{elif}\;y \leq 8:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.26 \cdot 10^{+92} \lor \neg \left(y \leq 2.6 \cdot 10^{+210}\right):\\
\;\;\;\;\frac{x \cdot y}{-z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.7e274 or 1.26e92 < y < 2.5999999999999999e210Initial program 59.2%
Taylor expanded in z around inf 31.7%
Taylor expanded in x around 0 30.0%
*-commutative30.0%
Simplified30.0%
associate-/l*74.9%
*-commutative74.9%
Applied egg-rr74.9%
if -1.7e274 < y < -6.3000000000000001e174Initial program 84.4%
Taylor expanded in y around inf 84.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 81.6%
neg-mul-181.6%
Simplified81.6%
if -6.3000000000000001e174 < y < 8Initial program 94.4%
Taylor expanded in z around inf 87.8%
Taylor expanded in x around 0 91.5%
+-commutative91.5%
Simplified91.5%
if 8 < y < 1.26e92 or 2.5999999999999999e210 < y Initial program 93.6%
Taylor expanded in y around inf 91.3%
associate-/l*97.4%
div-sub97.4%
*-inverses97.4%
Simplified97.4%
Taylor expanded in x around inf 74.1%
mul-1-neg74.1%
*-commutative74.1%
distribute-frac-neg274.1%
Simplified74.1%
Final simplification85.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ y z))) (t_1 (* y (/ (- x) z))))
(if (<= y -2.6e+269)
t_0
(if (<= y -4.8e+173)
t_1
(if (<= y 9.0)
(+ y (/ x z))
(if (or (<= y 1.08e+92) (not (<= y 8.8e+207))) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double t_1 = y * (-x / z);
double tmp;
if (y <= -2.6e+269) {
tmp = t_0;
} else if (y <= -4.8e+173) {
tmp = t_1;
} else if (y <= 9.0) {
tmp = y + (x / z);
} else if ((y <= 1.08e+92) || !(y <= 8.8e+207)) {
tmp = t_1;
} else {
tmp = t_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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z * (y / z)
t_1 = y * (-x / z)
if (y <= (-2.6d+269)) then
tmp = t_0
else if (y <= (-4.8d+173)) then
tmp = t_1
else if (y <= 9.0d0) then
tmp = y + (x / z)
else if ((y <= 1.08d+92) .or. (.not. (y <= 8.8d+207))) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y / z);
double t_1 = y * (-x / z);
double tmp;
if (y <= -2.6e+269) {
tmp = t_0;
} else if (y <= -4.8e+173) {
tmp = t_1;
} else if (y <= 9.0) {
tmp = y + (x / z);
} else if ((y <= 1.08e+92) || !(y <= 8.8e+207)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) t_1 = y * (-x / z) tmp = 0 if y <= -2.6e+269: tmp = t_0 elif y <= -4.8e+173: tmp = t_1 elif y <= 9.0: tmp = y + (x / z) elif (y <= 1.08e+92) or not (y <= 8.8e+207): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y / z)) t_1 = Float64(y * Float64(Float64(-x) / z)) tmp = 0.0 if (y <= -2.6e+269) tmp = t_0; elseif (y <= -4.8e+173) tmp = t_1; elseif (y <= 9.0) tmp = Float64(y + Float64(x / z)); elseif ((y <= 1.08e+92) || !(y <= 8.8e+207)) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y / z); t_1 = y * (-x / z); tmp = 0.0; if (y <= -2.6e+269) tmp = t_0; elseif (y <= -4.8e+173) tmp = t_1; elseif (y <= 9.0) tmp = y + (x / z); elseif ((y <= 1.08e+92) || ~((y <= 8.8e+207))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.6e+269], t$95$0, If[LessEqual[y, -4.8e+173], t$95$1, If[LessEqual[y, 9.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.08e+92], N[Not[LessEqual[y, 8.8e+207]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
t_1 := y \cdot \frac{-x}{z}\\
\mathbf{if}\;y \leq -2.6 \cdot 10^{+269}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{+173}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+92} \lor \neg \left(y \leq 8.8 \cdot 10^{+207}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.6e269 or 1.08e92 < y < 8.80000000000000034e207Initial program 59.2%
Taylor expanded in z around inf 31.7%
Taylor expanded in x around 0 30.0%
*-commutative30.0%
Simplified30.0%
associate-/l*74.9%
*-commutative74.9%
Applied egg-rr74.9%
if -2.6e269 < y < -4.7999999999999998e173 or 9 < y < 1.08e92 or 8.80000000000000034e207 < y Initial program 90.9%
Taylor expanded in y around inf 89.2%
associate-/l*98.2%
Simplified98.2%
Taylor expanded in z around 0 76.2%
neg-mul-176.2%
Simplified76.2%
if -4.7999999999999998e173 < y < 9Initial program 94.4%
Taylor expanded in z around inf 87.8%
Taylor expanded in x around 0 91.5%
+-commutative91.5%
Simplified91.5%
Final simplification85.3%
(FPCore (x y z)
:precision binary64
(if (<= y 5.5)
(+ y (/ x z))
(if (or (<= y 1.02e+92) (not (<= y 1.6e+211)))
(* x (/ (- y) z))
(* z (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.5) {
tmp = y + (x / z);
} else if ((y <= 1.02e+92) || !(y <= 1.6e+211)) {
tmp = x * (-y / z);
} else {
tmp = z * (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 <= 5.5d0) then
tmp = y + (x / z)
else if ((y <= 1.02d+92) .or. (.not. (y <= 1.6d+211))) then
tmp = x * (-y / z)
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5.5) {
tmp = y + (x / z);
} else if ((y <= 1.02e+92) || !(y <= 1.6e+211)) {
tmp = x * (-y / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.5: tmp = y + (x / z) elif (y <= 1.02e+92) or not (y <= 1.6e+211): tmp = x * (-y / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.5) tmp = Float64(y + Float64(x / z)); elseif ((y <= 1.02e+92) || !(y <= 1.6e+211)) tmp = Float64(x * Float64(Float64(-y) / z)); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.5) tmp = y + (x / z); elseif ((y <= 1.02e+92) || ~((y <= 1.6e+211))) tmp = x * (-y / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.5], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.02e+92], N[Not[LessEqual[y, 1.6e+211]], $MachinePrecision]], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+92} \lor \neg \left(y \leq 1.6 \cdot 10^{+211}\right):\\
\;\;\;\;x \cdot \frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 5.5Initial program 91.7%
Taylor expanded in z around inf 80.8%
Taylor expanded in x around 0 86.5%
+-commutative86.5%
Simplified86.5%
if 5.5 < y < 1.02000000000000003e92 or 1.59999999999999988e211 < y Initial program 93.6%
Taylor expanded in x around inf 75.8%
associate-/l*70.4%
mul-1-neg70.4%
unsub-neg70.4%
Simplified70.4%
Taylor expanded in y around inf 68.6%
neg-mul-168.6%
Simplified68.6%
if 1.02000000000000003e92 < y < 1.59999999999999988e211Initial program 59.7%
Taylor expanded in z around inf 31.0%
Taylor expanded in x around 0 31.5%
*-commutative31.5%
Simplified31.5%
associate-/l*68.9%
*-commutative68.9%
Applied egg-rr68.9%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e-25) (not (<= z 3e-36))) (+ (/ x z) (* y (- 1.0 (/ x z)))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-25) || !(z <= 3e-36)) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = (x + (y * (z - x))) / 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 <= (-1d-25)) .or. (.not. (z <= 3d-36))) then
tmp = (x / z) + (y * (1.0d0 - (x / z)))
else
tmp = (x + (y * (z - x))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-25) || !(z <= 3e-36)) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-25) or not (z <= 3e-36): tmp = (x / z) + (y * (1.0 - (x / z))) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-25) || !(z <= 3e-36)) tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); else tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e-25) || ~((z <= 3e-36))) tmp = (x / z) + (y * (1.0 - (x / z))); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-25], N[Not[LessEqual[z, 3e-36]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-25} \lor \neg \left(z \leq 3 \cdot 10^{-36}\right):\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if z < -1.00000000000000004e-25 or 3.0000000000000002e-36 < z Initial program 77.0%
Taylor expanded in y around 0 99.9%
if -1.00000000000000004e-25 < z < 3.0000000000000002e-36Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.8e+31) (not (<= y 3e+75))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+31) || !(y <= 3e+75)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / 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 <= (-2.8d+31)) .or. (.not. (y <= 3d+75))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = (x + (y * (z - x))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+31) || !(y <= 3e+75)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.8e+31) or not (y <= 3e+75): tmp = y * (1.0 - (x / z)) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.8e+31) || !(y <= 3e+75)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.8e+31) || ~((y <= 3e+75))) tmp = y * (1.0 - (x / z)); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.8e+31], N[Not[LessEqual[y, 3e+75]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+31} \lor \neg \left(y \leq 3 \cdot 10^{+75}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if y < -2.80000000000000017e31 or 3e75 < y Initial program 74.1%
Taylor expanded in y around inf 74.1%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
if -2.80000000000000017e31 < y < 3e75Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -23500000.0) (not (<= y 0.0052))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -23500000.0) || !(y <= 0.0052)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / 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 <= (-23500000.0d0)) .or. (.not. (y <= 0.0052d0))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -23500000.0) || !(y <= 0.0052)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -23500000.0) or not (y <= 0.0052): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -23500000.0) || !(y <= 0.0052)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -23500000.0) || ~((y <= 0.0052))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -23500000.0], N[Not[LessEqual[y, 0.0052]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -23500000 \lor \neg \left(y \leq 0.0052\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -2.35e7 or 0.0051999999999999998 < y Initial program 78.0%
Taylor expanded in y around inf 77.3%
associate-/l*99.1%
div-sub99.1%
*-inverses99.1%
Simplified99.1%
if -2.35e7 < y < 0.0051999999999999998Initial program 99.9%
Taylor expanded in z around inf 98.0%
Taylor expanded in x around 0 98.0%
+-commutative98.0%
Simplified98.0%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.2) (not (<= x 3.5e+137))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.2) || !(x <= 3.5e+137)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / 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 ((x <= (-1.2d0)) .or. (.not. (x <= 3.5d+137))) then
tmp = x * ((1.0d0 - y) / z)
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.2) || !(x <= 3.5e+137)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.2) or not (x <= 3.5e+137): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.2) || !(x <= 3.5e+137)) tmp = Float64(x * Float64(Float64(1.0 - y) / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.2) || ~((x <= 3.5e+137))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.2], N[Not[LessEqual[x, 3.5e+137]], $MachinePrecision]], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \lor \neg \left(x \leq 3.5 \cdot 10^{+137}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -1.19999999999999996 or 3.5000000000000001e137 < x Initial program 89.0%
Taylor expanded in x around inf 83.1%
associate-/l*89.5%
mul-1-neg89.5%
unsub-neg89.5%
Simplified89.5%
if -1.19999999999999996 < x < 3.5000000000000001e137Initial program 86.9%
Taylor expanded in z around inf 69.8%
Taylor expanded in x around 0 82.9%
+-commutative82.9%
Simplified82.9%
Final simplification86.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.0095) (not (<= y 0.00195))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0095) || !(y <= 0.00195)) {
tmp = z * (y / z);
} else {
tmp = x / 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.0095d0)) .or. (.not. (y <= 0.00195d0))) then
tmp = z * (y / z)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0095) || !(y <= 0.00195)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.0095) or not (y <= 0.00195): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.0095) || !(y <= 0.00195)) tmp = Float64(z * Float64(y / z)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.0095) || ~((y <= 0.00195))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.0095], N[Not[LessEqual[y, 0.00195]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0095 \lor \neg \left(y \leq 0.00195\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -0.00949999999999999976 or 0.0019499999999999999 < y Initial program 78.3%
Taylor expanded in z around inf 36.9%
Taylor expanded in x around 0 28.8%
*-commutative28.8%
Simplified28.8%
associate-/l*55.0%
*-commutative55.0%
Applied egg-rr55.0%
if -0.00949999999999999976 < y < 0.0019499999999999999Initial program 99.9%
Taylor expanded in y around 0 79.0%
Final simplification65.7%
(FPCore (x y z) :precision binary64 (if (<= y -0.0056) y (if (<= y 0.00145) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -0.0056) {
tmp = y;
} else if (y <= 0.00145) {
tmp = x / z;
} else {
tmp = 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 (y <= (-0.0056d0)) then
tmp = y
else if (y <= 0.00145d0) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -0.0056) {
tmp = y;
} else if (y <= 0.00145) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -0.0056: tmp = y elif y <= 0.00145: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -0.0056) tmp = y; elseif (y <= 0.00145) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -0.0056) tmp = y; elseif (y <= 0.00145) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -0.0056], y, If[LessEqual[y, 0.00145], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0056:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.00145:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -0.00559999999999999994 or 0.00145 < y Initial program 78.3%
Taylor expanded in x around 0 44.3%
if -0.00559999999999999994 < y < 0.00145Initial program 99.9%
Taylor expanded in y around 0 79.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (* z (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = z * (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 <= 1.0d0) then
tmp = y + (x / z)
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.0) tmp = y + (x / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 1Initial program 91.7%
Taylor expanded in z around inf 80.8%
Taylor expanded in x around 0 86.5%
+-commutative86.5%
Simplified86.5%
if 1 < y Initial program 78.7%
Taylor expanded in z around inf 23.7%
Taylor expanded in x around 0 24.5%
*-commutative24.5%
Simplified24.5%
associate-/l*48.8%
*-commutative48.8%
Applied egg-rr48.8%
Final simplification75.4%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 87.9%
Taylor expanded in x around 0 33.4%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (x / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2024123
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(! :herbie-platform default (- (+ y (/ x z)) (/ y (/ z x))))
(/ (+ x (* y (- z x))) z))