
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) * (3.0d0 - x)) / (y * 3.0d0)
end function
public static double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
def code(x, y): return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
function code(x, y) return Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0)) end
function tmp = code(x, y) tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) * (3.0d0 - x)) / (y * 3.0d0)
end function
public static double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
def code(x, y): return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
function code(x, y) return Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0)) end
function tmp = code(x, y) tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\end{array}
(FPCore (x y) :precision binary64 (/ (/ (- 3.0 x) 3.0) (/ y (- 1.0 x))))
double code(double x, double y) {
return ((3.0 - x) / 3.0) / (y / (1.0 - x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((3.0d0 - x) / 3.0d0) / (y / (1.0d0 - x))
end function
public static double code(double x, double y) {
return ((3.0 - x) / 3.0) / (y / (1.0 - x));
}
def code(x, y): return ((3.0 - x) / 3.0) / (y / (1.0 - x))
function code(x, y) return Float64(Float64(Float64(3.0 - x) / 3.0) / Float64(y / Float64(1.0 - x))) end
function tmp = code(x, y) tmp = ((3.0 - x) / 3.0) / (y / (1.0 - x)); end
code[x_, y_] := N[(N[(N[(3.0 - x), $MachinePrecision] / 3.0), $MachinePrecision] / N[(y / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{3 - x}{3}}{\frac{y}{1 - x}}
\end{array}
Initial program 93.4%
times-fracN/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.8%
Applied egg-rr99.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (/ x y) (+ (* x 0.3333333333333333) -1.3333333333333333))))
(if (<= x -1.72)
t_0
(if (<= x 1.75) (/ (+ 1.0 (* x -1.3333333333333333)) y) t_0))))
double code(double x, double y) {
double t_0 = (x / y) * ((x * 0.3333333333333333) + -1.3333333333333333);
double tmp;
if (x <= -1.72) {
tmp = t_0;
} else if (x <= 1.75) {
tmp = (1.0 + (x * -1.3333333333333333)) / y;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x / y) * ((x * 0.3333333333333333d0) + (-1.3333333333333333d0))
if (x <= (-1.72d0)) then
tmp = t_0
else if (x <= 1.75d0) then
tmp = (1.0d0 + (x * (-1.3333333333333333d0))) / y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) * ((x * 0.3333333333333333) + -1.3333333333333333);
double tmp;
if (x <= -1.72) {
tmp = t_0;
} else if (x <= 1.75) {
tmp = (1.0 + (x * -1.3333333333333333)) / y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) * ((x * 0.3333333333333333) + -1.3333333333333333) tmp = 0 if x <= -1.72: tmp = t_0 elif x <= 1.75: tmp = (1.0 + (x * -1.3333333333333333)) / y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) * Float64(Float64(x * 0.3333333333333333) + -1.3333333333333333)) tmp = 0.0 if (x <= -1.72) tmp = t_0; elseif (x <= 1.75) tmp = Float64(Float64(1.0 + Float64(x * -1.3333333333333333)) / y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) * ((x * 0.3333333333333333) + -1.3333333333333333); tmp = 0.0; if (x <= -1.72) tmp = t_0; elseif (x <= 1.75) tmp = (1.0 + (x * -1.3333333333333333)) / y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] + -1.3333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.72], t$95$0, If[LessEqual[x, 1.75], N[(N[(1.0 + N[(x * -1.3333333333333333), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \left(x \cdot 0.3333333333333333 + -1.3333333333333333\right)\\
\mathbf{if}\;x \leq -1.72:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.75:\\
\;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.71999999999999997 or 1.75 < x Initial program 87.6%
Taylor expanded in x around inf
sub-negN/A
distribute-lft-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-*r/N/A
metadata-evalN/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
times-fracN/A
Simplified98.9%
if -1.71999999999999997 < x < 1.75Initial program 99.7%
Taylor expanded in x around 0
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
unpow2N/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
associate-*r*N/A
Simplified98.7%
Taylor expanded in y around 0
associate-*r/N/A
/-lowering-/.f64N/A
distribute-lft-inN/A
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
+-lowering-+.f64N/A
*-lowering-*.f6499.0%
Simplified99.0%
Final simplification98.9%
(FPCore (x y)
:precision binary64
(if (<= x -4.7)
(/ x (/ y (/ x 3.0)))
(if (<= x 3.0)
(/ (+ 1.0 (* x -1.3333333333333333)) y)
(/ (/ x y) (/ 3.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -4.7) {
tmp = x / (y / (x / 3.0));
} else if (x <= 3.0) {
tmp = (1.0 + (x * -1.3333333333333333)) / y;
} else {
tmp = (x / y) / (3.0 / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-4.7d0)) then
tmp = x / (y / (x / 3.0d0))
else if (x <= 3.0d0) then
tmp = (1.0d0 + (x * (-1.3333333333333333d0))) / y
else
tmp = (x / y) / (3.0d0 / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -4.7) {
tmp = x / (y / (x / 3.0));
} else if (x <= 3.0) {
tmp = (1.0 + (x * -1.3333333333333333)) / y;
} else {
tmp = (x / y) / (3.0 / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.7: tmp = x / (y / (x / 3.0)) elif x <= 3.0: tmp = (1.0 + (x * -1.3333333333333333)) / y else: tmp = (x / y) / (3.0 / x) return tmp
function code(x, y) tmp = 0.0 if (x <= -4.7) tmp = Float64(x / Float64(y / Float64(x / 3.0))); elseif (x <= 3.0) tmp = Float64(Float64(1.0 + Float64(x * -1.3333333333333333)) / y); else tmp = Float64(Float64(x / y) / Float64(3.0 / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4.7) tmp = x / (y / (x / 3.0)); elseif (x <= 3.0) tmp = (1.0 + (x * -1.3333333333333333)) / y; else tmp = (x / y) / (3.0 / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.7], N[(x / N[(y / N[(x / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.0], N[(N[(1.0 + N[(x * -1.3333333333333333), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(3.0 / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.7:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\
\mathbf{elif}\;x \leq 3:\\
\;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{3}{x}}\\
\end{array}
\end{array}
if x < -4.70000000000000018Initial program 86.8%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6485.2%
Simplified85.2%
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
associate-*l*N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6498.1%
Applied egg-rr98.1%
associate-*r/N/A
metadata-evalN/A
div-invN/A
div-invN/A
clear-numN/A
clear-numN/A
times-fracN/A
*-lft-identityN/A
/-lowering-/.f64N/A
*-commutativeN/A
clear-numN/A
div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6498.3%
Applied egg-rr98.3%
if -4.70000000000000018 < x < 3Initial program 99.6%
Taylor expanded in x around 0
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
unpow2N/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
associate-*r*N/A
Simplified98.0%
Taylor expanded in y around 0
associate-*r/N/A
/-lowering-/.f64N/A
distribute-lft-inN/A
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
+-lowering-+.f64N/A
*-lowering-*.f6498.3%
Simplified98.3%
if 3 < x Initial program 88.4%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6488.0%
Simplified88.0%
*-commutativeN/A
associate-*l*N/A
associate-*l/N/A
metadata-evalN/A
div-invN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6499.4%
Applied egg-rr99.4%
Final simplification98.6%
(FPCore (x y)
:precision binary64
(if (<= x -4.7)
(/ x (/ y (/ x 3.0)))
(if (<= x 3.0)
(/ (+ 1.0 (* x -1.3333333333333333)) y)
(* (/ x y) (/ x 3.0)))))
double code(double x, double y) {
double tmp;
if (x <= -4.7) {
tmp = x / (y / (x / 3.0));
} else if (x <= 3.0) {
tmp = (1.0 + (x * -1.3333333333333333)) / y;
} else {
tmp = (x / y) * (x / 3.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-4.7d0)) then
tmp = x / (y / (x / 3.0d0))
else if (x <= 3.0d0) then
tmp = (1.0d0 + (x * (-1.3333333333333333d0))) / y
else
tmp = (x / y) * (x / 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -4.7) {
tmp = x / (y / (x / 3.0));
} else if (x <= 3.0) {
tmp = (1.0 + (x * -1.3333333333333333)) / y;
} else {
tmp = (x / y) * (x / 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.7: tmp = x / (y / (x / 3.0)) elif x <= 3.0: tmp = (1.0 + (x * -1.3333333333333333)) / y else: tmp = (x / y) * (x / 3.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -4.7) tmp = Float64(x / Float64(y / Float64(x / 3.0))); elseif (x <= 3.0) tmp = Float64(Float64(1.0 + Float64(x * -1.3333333333333333)) / y); else tmp = Float64(Float64(x / y) * Float64(x / 3.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4.7) tmp = x / (y / (x / 3.0)); elseif (x <= 3.0) tmp = (1.0 + (x * -1.3333333333333333)) / y; else tmp = (x / y) * (x / 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.7], N[(x / N[(y / N[(x / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.0], N[(N[(1.0 + N[(x * -1.3333333333333333), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.7:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\
\mathbf{elif}\;x \leq 3:\\
\;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\
\end{array}
\end{array}
if x < -4.70000000000000018Initial program 86.8%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6485.2%
Simplified85.2%
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
associate-*l*N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6498.1%
Applied egg-rr98.1%
associate-*r/N/A
metadata-evalN/A
div-invN/A
div-invN/A
clear-numN/A
clear-numN/A
times-fracN/A
*-lft-identityN/A
/-lowering-/.f64N/A
*-commutativeN/A
clear-numN/A
div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6498.3%
Applied egg-rr98.3%
if -4.70000000000000018 < x < 3Initial program 99.6%
Taylor expanded in x around 0
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
unpow2N/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
associate-*r*N/A
Simplified98.0%
Taylor expanded in y around 0
associate-*r/N/A
/-lowering-/.f64N/A
distribute-lft-inN/A
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
+-lowering-+.f64N/A
*-lowering-*.f6498.3%
Simplified98.3%
if 3 < x Initial program 88.4%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6488.0%
Simplified88.0%
*-commutativeN/A
associate-*l*N/A
associate-*l/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
div-invN/A
/-lowering-/.f6499.3%
Applied egg-rr99.3%
Final simplification98.5%
(FPCore (x y) :precision binary64 (if (<= x -1.72) (/ x (/ y (/ x 3.0))) (if (<= x 0.56) (/ 1.0 y) (* (/ x y) (/ x 3.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.72) {
tmp = x / (y / (x / 3.0));
} else if (x <= 0.56) {
tmp = 1.0 / y;
} else {
tmp = (x / y) * (x / 3.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.72d0)) then
tmp = x / (y / (x / 3.0d0))
else if (x <= 0.56d0) then
tmp = 1.0d0 / y
else
tmp = (x / y) * (x / 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.72) {
tmp = x / (y / (x / 3.0));
} else if (x <= 0.56) {
tmp = 1.0 / y;
} else {
tmp = (x / y) * (x / 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.72: tmp = x / (y / (x / 3.0)) elif x <= 0.56: tmp = 1.0 / y else: tmp = (x / y) * (x / 3.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.72) tmp = Float64(x / Float64(y / Float64(x / 3.0))); elseif (x <= 0.56) tmp = Float64(1.0 / y); else tmp = Float64(Float64(x / y) * Float64(x / 3.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.72) tmp = x / (y / (x / 3.0)); elseif (x <= 0.56) tmp = 1.0 / y; else tmp = (x / y) * (x / 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.72], N[(x / N[(y / N[(x / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.56], N[(1.0 / y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.72:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\
\mathbf{elif}\;x \leq 0.56:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\
\end{array}
\end{array}
if x < -1.71999999999999997Initial program 87.0%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6484.3%
Simplified84.3%
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
associate-*l*N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6497.0%
Applied egg-rr97.0%
associate-*r/N/A
metadata-evalN/A
div-invN/A
div-invN/A
clear-numN/A
clear-numN/A
times-fracN/A
*-lft-identityN/A
/-lowering-/.f64N/A
*-commutativeN/A
clear-numN/A
div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6497.2%
Applied egg-rr97.2%
if -1.71999999999999997 < x < 0.56000000000000005Initial program 99.7%
Taylor expanded in x around 0
/-lowering-/.f6497.6%
Simplified97.6%
if 0.56000000000000005 < x Initial program 88.4%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6488.0%
Simplified88.0%
*-commutativeN/A
associate-*l*N/A
associate-*l/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
div-invN/A
/-lowering-/.f6499.3%
Applied egg-rr99.3%
(FPCore (x y) :precision binary64 (let* ((t_0 (* (/ x y) (/ x 3.0)))) (if (<= x -1.72) t_0 (if (<= x 0.56) (/ 1.0 y) t_0))))
double code(double x, double y) {
double t_0 = (x / y) * (x / 3.0);
double tmp;
if (x <= -1.72) {
tmp = t_0;
} else if (x <= 0.56) {
tmp = 1.0 / y;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x / y) * (x / 3.0d0)
if (x <= (-1.72d0)) then
tmp = t_0
else if (x <= 0.56d0) then
tmp = 1.0d0 / y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x / y) * (x / 3.0);
double tmp;
if (x <= -1.72) {
tmp = t_0;
} else if (x <= 0.56) {
tmp = 1.0 / y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x / y) * (x / 3.0) tmp = 0 if x <= -1.72: tmp = t_0 elif x <= 0.56: tmp = 1.0 / y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x / y) * Float64(x / 3.0)) tmp = 0.0 if (x <= -1.72) tmp = t_0; elseif (x <= 0.56) tmp = Float64(1.0 / y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x / y) * (x / 3.0); tmp = 0.0; if (x <= -1.72) tmp = t_0; elseif (x <= 0.56) tmp = 1.0 / y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] * N[(x / 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.72], t$95$0, If[LessEqual[x, 0.56], N[(1.0 / y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \frac{x}{3}\\
\mathbf{if}\;x \leq -1.72:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.56:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.71999999999999997 or 0.56000000000000005 < x Initial program 87.6%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6485.9%
Simplified85.9%
*-commutativeN/A
associate-*l*N/A
associate-*l/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
div-invN/A
/-lowering-/.f6498.1%
Applied egg-rr98.1%
if -1.71999999999999997 < x < 0.56000000000000005Initial program 99.7%
Taylor expanded in x around 0
/-lowering-/.f6497.6%
Simplified97.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (* x (/ 0.3333333333333333 (/ y x))))) (if (<= x -1.72) t_0 (if (<= x 0.56) (/ 1.0 y) t_0))))
double code(double x, double y) {
double t_0 = x * (0.3333333333333333 / (y / x));
double tmp;
if (x <= -1.72) {
tmp = t_0;
} else if (x <= 0.56) {
tmp = 1.0 / y;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x * (0.3333333333333333d0 / (y / x))
if (x <= (-1.72d0)) then
tmp = t_0
else if (x <= 0.56d0) then
tmp = 1.0d0 / y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (0.3333333333333333 / (y / x));
double tmp;
if (x <= -1.72) {
tmp = t_0;
} else if (x <= 0.56) {
tmp = 1.0 / y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (0.3333333333333333 / (y / x)) tmp = 0 if x <= -1.72: tmp = t_0 elif x <= 0.56: tmp = 1.0 / y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(0.3333333333333333 / Float64(y / x))) tmp = 0.0 if (x <= -1.72) tmp = t_0; elseif (x <= 0.56) tmp = Float64(1.0 / y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (0.3333333333333333 / (y / x)); tmp = 0.0; if (x <= -1.72) tmp = t_0; elseif (x <= 0.56) tmp = 1.0 / y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(0.3333333333333333 / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.72], t$95$0, If[LessEqual[x, 0.56], N[(1.0 / y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{0.3333333333333333}{\frac{y}{x}}\\
\mathbf{if}\;x \leq -1.72:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.56:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.71999999999999997 or 0.56000000000000005 < x Initial program 87.6%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6485.9%
Simplified85.9%
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
associate-*l*N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6498.0%
Applied egg-rr98.0%
if -1.71999999999999997 < x < 0.56000000000000005Initial program 99.7%
Taylor expanded in x around 0
/-lowering-/.f6497.6%
Simplified97.6%
(FPCore (x y) :precision binary64 (/ (- 3.0 x) (/ (/ y 0.3333333333333333) (- 1.0 x))))
double code(double x, double y) {
return (3.0 - x) / ((y / 0.3333333333333333) / (1.0 - x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 - x) / ((y / 0.3333333333333333d0) / (1.0d0 - x))
end function
public static double code(double x, double y) {
return (3.0 - x) / ((y / 0.3333333333333333) / (1.0 - x));
}
def code(x, y): return (3.0 - x) / ((y / 0.3333333333333333) / (1.0 - x))
function code(x, y) return Float64(Float64(3.0 - x) / Float64(Float64(y / 0.3333333333333333) / Float64(1.0 - x))) end
function tmp = code(x, y) tmp = (3.0 - x) / ((y / 0.3333333333333333) / (1.0 - x)); end
code[x_, y_] := N[(N[(3.0 - x), $MachinePrecision] / N[(N[(y / 0.3333333333333333), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{3 - x}{\frac{\frac{y}{0.3333333333333333}}{1 - x}}
\end{array}
Initial program 93.4%
times-fracN/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.8%
Applied egg-rr99.8%
associate-/l/N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
associate-*l/N/A
/-lowering-/.f64N/A
metadata-evalN/A
div-invN/A
/-lowering-/.f64N/A
--lowering--.f6499.6%
Applied egg-rr99.6%
(FPCore (x y) :precision binary64 (* 0.3333333333333333 (/ (- 3.0 x) (/ y (- 1.0 x)))))
double code(double x, double y) {
return 0.3333333333333333 * ((3.0 - x) / (y / (1.0 - x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.3333333333333333d0 * ((3.0d0 - x) / (y / (1.0d0 - x)))
end function
public static double code(double x, double y) {
return 0.3333333333333333 * ((3.0 - x) / (y / (1.0 - x)));
}
def code(x, y): return 0.3333333333333333 * ((3.0 - x) / (y / (1.0 - x)))
function code(x, y) return Float64(0.3333333333333333 * Float64(Float64(3.0 - x) / Float64(y / Float64(1.0 - x)))) end
function tmp = code(x, y) tmp = 0.3333333333333333 * ((3.0 - x) / (y / (1.0 - x))); end
code[x_, y_] := N[(0.3333333333333333 * N[(N[(3.0 - x), $MachinePrecision] / N[(y / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.3333333333333333 \cdot \frac{3 - x}{\frac{y}{1 - x}}
\end{array}
Initial program 93.4%
associate-/r*N/A
div-invN/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (<= x -0.75) (* (/ x y) -1.3333333333333333) (/ 1.0 y)))
double code(double x, double y) {
double tmp;
if (x <= -0.75) {
tmp = (x / y) * -1.3333333333333333;
} else {
tmp = 1.0 / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.75d0)) then
tmp = (x / y) * (-1.3333333333333333d0)
else
tmp = 1.0d0 / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.75) {
tmp = (x / y) * -1.3333333333333333;
} else {
tmp = 1.0 / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.75: tmp = (x / y) * -1.3333333333333333 else: tmp = 1.0 / y return tmp
function code(x, y) tmp = 0.0 if (x <= -0.75) tmp = Float64(Float64(x / y) * -1.3333333333333333); else tmp = Float64(1.0 / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.75) tmp = (x / y) * -1.3333333333333333; else tmp = 1.0 / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.75], N[(N[(x / y), $MachinePrecision] * -1.3333333333333333), $MachinePrecision], N[(1.0 / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.75:\\
\;\;\;\;\frac{x}{y} \cdot -1.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y}\\
\end{array}
\end{array}
if x < -0.75Initial program 87.0%
Taylor expanded in x around inf
sub-negN/A
distribute-lft-inN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-*r/N/A
metadata-evalN/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
times-fracN/A
Simplified98.4%
Taylor expanded in x around 0
Simplified29.6%
if -0.75 < x Initial program 96.0%
Taylor expanded in x around 0
/-lowering-/.f6467.8%
Simplified67.8%
(FPCore (x y) :precision binary64 (/ 1.0 y))
double code(double x, double y) {
return 1.0 / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / y
end function
public static double code(double x, double y) {
return 1.0 / y;
}
def code(x, y): return 1.0 / y
function code(x, y) return Float64(1.0 / y) end
function tmp = code(x, y) tmp = 1.0 / y; end
code[x_, y_] := N[(1.0 / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{y}
\end{array}
Initial program 93.4%
Taylor expanded in x around 0
/-lowering-/.f6449.6%
Simplified49.6%
(FPCore (x y) :precision binary64 (* (/ (- 1.0 x) y) (/ (- 3.0 x) 3.0)))
double code(double x, double y) {
return ((1.0 - x) / y) * ((3.0 - x) / 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) / y) * ((3.0d0 - x) / 3.0d0)
end function
public static double code(double x, double y) {
return ((1.0 - x) / y) * ((3.0 - x) / 3.0);
}
def code(x, y): return ((1.0 - x) / y) * ((3.0 - x) / 3.0)
function code(x, y) return Float64(Float64(Float64(1.0 - x) / y) * Float64(Float64(3.0 - x) / 3.0)) end
function tmp = code(x, y) tmp = ((1.0 - x) / y) * ((3.0 - x) / 3.0); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] * N[(N[(3.0 - x), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{y} \cdot \frac{3 - x}{3}
\end{array}
herbie shell --seed 2024149
(FPCore (x y)
:name "Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (* (/ (- 1 x) y) (/ (- 3 x) 3)))
(/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))