
(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 5 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 (/ (- 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 85.5%
*-commutative85.5%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (* x (/ y (- t z))))
double code(double x, double y, double z, double t) {
return x * (y / (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 / (t - z))
end function
public static double code(double x, double y, double z, double t) {
return x * (y / (t - z));
}
def code(x, y, z, t): return x * (y / (t - z))
function code(x, y, z, t) return Float64(x * Float64(y / Float64(t - z))) end
function tmp = code(x, y, z, t) tmp = x * (y / (t - z)); end
code[x_, y_, z_, t_] := N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{t - z}
\end{array}
Initial program 85.5%
*-commutative85.5%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in y around inf 53.8%
Final simplification53.8%
(FPCore (x y z t) :precision binary64 (* x (/ z (- z t))))
double code(double x, double y, double z, double t) {
return x * (z / (z - t));
}
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 * (z / (z - t))
end function
public static double code(double x, double y, double z, double t) {
return x * (z / (z - t));
}
def code(x, y, z, t): return x * (z / (z - t))
function code(x, y, z, t) return Float64(x * Float64(z / Float64(z - t))) end
function tmp = code(x, y, z, t) tmp = x * (z / (z - t)); end
code[x_, y_, z_, t_] := N[(x * N[(z / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{z}{z - t}
\end{array}
Initial program 85.5%
*-commutative85.5%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in y around 0 56.4%
neg-mul-156.4%
distribute-neg-frac56.4%
Simplified56.4%
frac-2neg56.4%
div-inv56.4%
remove-double-neg56.4%
sub-neg56.4%
distribute-neg-in56.4%
remove-double-neg56.4%
Applied egg-rr56.4%
associate-*r/56.4%
*-rgt-identity56.4%
+-commutative56.4%
unsub-neg56.4%
Simplified56.4%
Final simplification56.4%
(FPCore (x y z t) :precision binary64 (* x (/ y t)))
double code(double x, double y, double z, double t) {
return x * (y / t);
}
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 / t)
end function
public static double code(double x, double y, double z, double t) {
return x * (y / t);
}
def code(x, y, z, t): return x * (y / t)
function code(x, y, z, t) return Float64(x * Float64(y / t)) end
function tmp = code(x, y, z, t) tmp = x * (y / t); end
code[x_, y_, z_, t_] := N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{t}
\end{array}
Initial program 85.5%
*-commutative85.5%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in z around 0 39.9%
Final simplification39.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 85.5%
*-commutative85.5%
associate-*l/98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in z around inf 37.5%
Final simplification37.5%
(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 2024033
(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)))