
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{t - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{t - z}
\end{array}
(FPCore (x y z t) :precision binary64 (/ x (/ (- t z) (- y z))))
double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / ((t - z) / (y - z))
end function
public static double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
def code(x, y, z, t): return x / ((t - z) / (y - z))
function code(x, y, z, t) return Float64(x / Float64(Float64(t - z) / Float64(y - z))) end
function tmp = code(x, y, z, t) tmp = x / ((t - z) / (y - z)); end
code[x_, y_, z_, t_] := N[(x / N[(N[(t - z), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{t - z}{y - z}}
\end{array}
Initial program 83.2%
associate-/l*97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (x y z t) :precision binary64 (if (or (<= t -8.3e+102) (not (<= t 48000000000000.0))) (* x (/ (- y z) t)) (/ x (/ (- z) (- y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.3e+102) || !(t <= 48000000000000.0)) {
tmp = x * ((y - z) / t);
} else {
tmp = x / (-z / (y - z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-8.3d+102)) .or. (.not. (t <= 48000000000000.0d0))) then
tmp = x * ((y - z) / t)
else
tmp = x / (-z / (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.3e+102) || !(t <= 48000000000000.0)) {
tmp = x * ((y - z) / t);
} else {
tmp = x / (-z / (y - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -8.3e+102) or not (t <= 48000000000000.0): tmp = x * ((y - z) / t) else: tmp = x / (-z / (y - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -8.3e+102) || !(t <= 48000000000000.0)) tmp = Float64(x * Float64(Float64(y - z) / t)); else tmp = Float64(x / Float64(Float64(-z) / Float64(y - z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -8.3e+102) || ~((t <= 48000000000000.0))) tmp = x * ((y - z) / t); else tmp = x / (-z / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -8.3e+102], N[Not[LessEqual[t, 48000000000000.0]], $MachinePrecision]], N[(x * N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x / N[((-z) / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8.3 \cdot 10^{+102} \lor \neg \left(t \leq 48000000000000\right):\\
\;\;\;\;x \cdot \frac{y - z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{-z}{y - z}}\\
\end{array}
\end{array}
if t < -8.3000000000000005e102 or 4.8e13 < t Initial program 80.0%
associate-*r/98.2%
Simplified98.2%
Taylor expanded in t around inf 79.1%
if -8.3000000000000005e102 < t < 4.8e13Initial program 85.8%
associate-/l*96.9%
Simplified96.9%
Taylor expanded in t around 0 79.7%
neg-mul-179.7%
distribute-neg-frac79.7%
Simplified79.7%
Final simplification79.5%
(FPCore (x y z t) :precision binary64 (if (or (<= t -8.3e+102) (not (<= t 75000000000000.0))) (* x (/ (- y z) t)) (- x (* y (/ x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.3e+102) || !(t <= 75000000000000.0)) {
tmp = x * ((y - z) / t);
} else {
tmp = x - (y * (x / z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-8.3d+102)) .or. (.not. (t <= 75000000000000.0d0))) then
tmp = x * ((y - z) / t)
else
tmp = x - (y * (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.3e+102) || !(t <= 75000000000000.0)) {
tmp = x * ((y - z) / t);
} else {
tmp = x - (y * (x / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -8.3e+102) or not (t <= 75000000000000.0): tmp = x * ((y - z) / t) else: tmp = x - (y * (x / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -8.3e+102) || !(t <= 75000000000000.0)) tmp = Float64(x * Float64(Float64(y - z) / t)); else tmp = Float64(x - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -8.3e+102) || ~((t <= 75000000000000.0))) tmp = x * ((y - z) / t); else tmp = x - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -8.3e+102], N[Not[LessEqual[t, 75000000000000.0]], $MachinePrecision]], N[(x * N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8.3 \cdot 10^{+102} \lor \neg \left(t \leq 75000000000000\right):\\
\;\;\;\;x \cdot \frac{y - z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if t < -8.3000000000000005e102 or 7.5e13 < t Initial program 80.0%
associate-*r/98.2%
Simplified98.2%
Taylor expanded in t around inf 79.1%
if -8.3000000000000005e102 < t < 7.5e13Initial program 85.8%
associate-*l/87.2%
Simplified87.2%
Taylor expanded in t around 0 68.4%
associate-*r/68.4%
neg-mul-168.4%
Simplified68.4%
Taylor expanded in z around 0 76.4%
+-commutative76.4%
mul-1-neg76.4%
unsub-neg76.4%
associate-*r/76.6%
Simplified76.6%
Final simplification77.7%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.32e+103) (not (<= t 24000000000000.0))) (* x (/ (- y z) t)) (- x (/ x (/ z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.32e+103) || !(t <= 24000000000000.0)) {
tmp = x * ((y - z) / t);
} else {
tmp = x - (x / (z / y));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-1.32d+103)) .or. (.not. (t <= 24000000000000.0d0))) then
tmp = x * ((y - z) / t)
else
tmp = x - (x / (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.32e+103) || !(t <= 24000000000000.0)) {
tmp = x * ((y - z) / t);
} else {
tmp = x - (x / (z / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.32e+103) or not (t <= 24000000000000.0): tmp = x * ((y - z) / t) else: tmp = x - (x / (z / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.32e+103) || !(t <= 24000000000000.0)) tmp = Float64(x * Float64(Float64(y - z) / t)); else tmp = Float64(x - Float64(x / Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.32e+103) || ~((t <= 24000000000000.0))) tmp = x * ((y - z) / t); else tmp = x - (x / (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.32e+103], N[Not[LessEqual[t, 24000000000000.0]], $MachinePrecision]], N[(x * N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.32 \cdot 10^{+103} \lor \neg \left(t \leq 24000000000000\right):\\
\;\;\;\;x \cdot \frac{y - z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if t < -1.31999999999999999e103 or 2.4e13 < t Initial program 80.0%
associate-*r/98.2%
Simplified98.2%
Taylor expanded in t around inf 79.1%
if -1.31999999999999999e103 < t < 2.4e13Initial program 85.8%
associate-/l*96.9%
Simplified96.9%
Taylor expanded in t around 0 79.7%
neg-mul-179.7%
distribute-neg-frac79.7%
Simplified79.7%
Taylor expanded in z around 0 76.4%
+-commutative76.4%
mul-1-neg76.4%
*-commutative76.4%
associate-*r/79.7%
unsub-neg79.7%
associate-*r/76.4%
associate-/l*79.7%
Simplified79.7%
Final simplification79.5%
(FPCore (x y z t) :precision binary64 (if (<= z -4.5e+115) x (if (<= z 7.6e+120) (* x (/ y (- t z))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.5e+115) {
tmp = x;
} else if (z <= 7.6e+120) {
tmp = x * (y / (t - z));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-4.5d+115)) then
tmp = x
else if (z <= 7.6d+120) then
tmp = x * (y / (t - z))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.5e+115) {
tmp = x;
} else if (z <= 7.6e+120) {
tmp = x * (y / (t - z));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.5e+115: tmp = x elif z <= 7.6e+120: tmp = x * (y / (t - z)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.5e+115) tmp = x; elseif (z <= 7.6e+120) tmp = Float64(x * Float64(y / Float64(t - z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -4.5e+115) tmp = x; elseif (z <= 7.6e+120) tmp = x * (y / (t - z)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.5e+115], x, If[LessEqual[z, 7.6e+120], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+115}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{+120}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.49999999999999963e115 or 7.5999999999999995e120 < z Initial program 69.3%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in z around inf 72.1%
if -4.49999999999999963e115 < z < 7.5999999999999995e120Initial program 89.2%
associate-*r/95.6%
Simplified95.6%
Taylor expanded in y around inf 74.1%
Final simplification73.5%
(FPCore (x y z t) :precision binary64 (if (<= z -5.7e+25) x (if (<= z 2.15e+101) (* x (/ y t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.7e+25) {
tmp = x;
} else if (z <= 2.15e+101) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-5.7d+25)) then
tmp = x
else if (z <= 2.15d+101) then
tmp = x * (y / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.7e+25) {
tmp = x;
} else if (z <= 2.15e+101) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.7e+25: tmp = x elif z <= 2.15e+101: tmp = x * (y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.7e+25) tmp = x; elseif (z <= 2.15e+101) tmp = Float64(x * Float64(y / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.7e+25) tmp = x; elseif (z <= 2.15e+101) tmp = x * (y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.7e+25], x, If[LessEqual[z, 2.15e+101], N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.7 \cdot 10^{+25}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{+101}:\\
\;\;\;\;x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.6999999999999996e25 or 2.15e101 < z Initial program 68.6%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in z around inf 63.9%
if -5.6999999999999996e25 < z < 2.15e101Initial program 92.0%
associate-*r/95.1%
Simplified95.1%
Taylor expanded in z around 0 57.6%
Final simplification59.9%
(FPCore (x y z t) :precision binary64 (* x (/ (- y z) (- t z))))
double code(double x, double y, double z, double t) {
return x * ((y - z) / (t - z));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * ((y - z) / (t - z))
end function
public static double code(double x, double y, double z, double t) {
return x * ((y - z) / (t - z));
}
def code(x, y, z, t): return x * ((y - z) / (t - z))
function code(x, y, z, t) return Float64(x * Float64(Float64(y - z) / Float64(t - z))) end
function tmp = code(x, y, z, t) tmp = x * ((y - z) / (t - z)); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y - z), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y - z}{t - z}
\end{array}
Initial program 83.2%
associate-*r/96.9%
Simplified96.9%
Final simplification96.9%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 83.2%
associate-*r/96.9%
Simplified96.9%
Taylor expanded in z around inf 32.8%
Final simplification32.8%
(FPCore (x y z t) :precision binary64 (/ x (/ (- t z) (- y z))))
double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / ((t - z) / (y - z))
end function
public static double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
def code(x, y, z, t): return x / ((t - z) / (y - z))
function code(x, y, z, t) return Float64(x / Float64(Float64(t - z) / Float64(y - z))) end
function tmp = code(x, y, z, t) tmp = x / ((t - z) / (y - z)); end
code[x_, y_, z_, t_] := N[(x / N[(N[(t - z), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{t - z}{y - z}}
\end{array}
herbie shell --seed 2023199
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
:precision binary64
:herbie-target
(/ x (/ (- t z) (- y z)))
(/ (* x (- y z)) (- t z)))