
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
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) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
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) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y 2.7e+157) (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e+157) {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
} else {
tmp = x + (z * (t - 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 (y <= 2.7d+157) then
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e+157) {
tmp = x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.7e+157: tmp = x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y))))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.7e+157) tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.7e+157) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.7e+157], N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{+157}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.7e157Initial program 96.1%
associate-*l*97.5%
Simplified97.5%
if 2.7e157 < y Initial program 79.8%
associate-*l*79.7%
Simplified79.7%
Taylor expanded in y around inf 94.8%
Final simplification97.1%
(FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 93.9%
+-commutative93.9%
*-commutative93.9%
associate-*l*96.4%
fma-def96.4%
Simplified96.4%
Final simplification96.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y -2.1e-67)
(fma z (- (* y t_1) x) x)
(if (<= y 2.5e+145) (+ x (* t_1 (* z y))) (+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= -2.1e-67) {
tmp = fma(z, ((y * t_1) - x), x);
} else if (y <= 2.5e+145) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= -2.1e-67) tmp = fma(z, Float64(Float64(y * t_1) - x), x); elseif (y <= 2.5e+145) tmp = Float64(x + Float64(t_1 * Float64(z * y))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -2.1e-67], N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.5e+145], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{-67}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1 - x, x\right)\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+145}:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < -2.1000000000000002e-67Initial program 92.0%
+-commutative92.0%
*-commutative92.0%
associate-*l*95.1%
fma-def95.1%
Simplified95.1%
Taylor expanded in x around 0 45.2%
+-commutative45.2%
mul-1-neg45.2%
unsub-neg45.2%
Simplified87.5%
if -2.1000000000000002e-67 < y < 2.49999999999999983e145Initial program 99.2%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 21.8%
*-commutative21.8%
associate-/r*21.8%
div-sub21.8%
rec-exp21.8%
rec-exp21.8%
Simplified88.7%
if 2.49999999999999983e145 < y Initial program 79.4%
associate-*l*81.5%
Simplified81.5%
Taylor expanded in y around inf 92.9%
Final simplification89.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* (tanh (/ t y)) (* z y)))) (t_2 (+ x (* z (- t x)))))
(if (<= y -6.8e+127)
t_2
(if (<= y -8.8e+38)
t_1
(if (<= y -1.35e-21)
(+ x (* (* z y) (- (/ t y) (tanh (/ x y)))))
(if (<= y 2.6e+145) t_1 t_2))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (tanh((t / y)) * (z * y));
double t_2 = x + (z * (t - x));
double tmp;
if (y <= -6.8e+127) {
tmp = t_2;
} else if (y <= -8.8e+38) {
tmp = t_1;
} else if (y <= -1.35e-21) {
tmp = x + ((z * y) * ((t / y) - tanh((x / y))));
} else if (y <= 2.6e+145) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x + (tanh((t / y)) * (z * y))
t_2 = x + (z * (t - x))
if (y <= (-6.8d+127)) then
tmp = t_2
else if (y <= (-8.8d+38)) then
tmp = t_1
else if (y <= (-1.35d-21)) then
tmp = x + ((z * y) * ((t / y) - tanh((x / y))))
else if (y <= 2.6d+145) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (Math.tanh((t / y)) * (z * y));
double t_2 = x + (z * (t - x));
double tmp;
if (y <= -6.8e+127) {
tmp = t_2;
} else if (y <= -8.8e+38) {
tmp = t_1;
} else if (y <= -1.35e-21) {
tmp = x + ((z * y) * ((t / y) - Math.tanh((x / y))));
} else if (y <= 2.6e+145) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (math.tanh((t / y)) * (z * y)) t_2 = x + (z * (t - x)) tmp = 0 if y <= -6.8e+127: tmp = t_2 elif y <= -8.8e+38: tmp = t_1 elif y <= -1.35e-21: tmp = x + ((z * y) * ((t / y) - math.tanh((x / y)))) elif y <= 2.6e+145: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))) t_2 = Float64(x + Float64(z * Float64(t - x))) tmp = 0.0 if (y <= -6.8e+127) tmp = t_2; elseif (y <= -8.8e+38) tmp = t_1; elseif (y <= -1.35e-21) tmp = Float64(x + Float64(Float64(z * y) * Float64(Float64(t / y) - tanh(Float64(x / y))))); elseif (y <= 2.6e+145) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (tanh((t / y)) * (z * y)); t_2 = x + (z * (t - x)); tmp = 0.0; if (y <= -6.8e+127) tmp = t_2; elseif (y <= -8.8e+38) tmp = t_1; elseif (y <= -1.35e-21) tmp = x + ((z * y) * ((t / y) - tanh((x / y)))); elseif (y <= 2.6e+145) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.8e+127], t$95$2, If[LessEqual[y, -8.8e+38], t$95$1, If[LessEqual[y, -1.35e-21], N[(x + N[(N[(z * y), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+145], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
t_2 := x + z \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -6.8 \cdot 10^{+127}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq -8.8 \cdot 10^{+38}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{-21}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+145}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if y < -6.79999999999999955e127 or 2.60000000000000003e145 < y Initial program 81.0%
associate-*l*83.8%
Simplified83.8%
Taylor expanded in y around inf 92.8%
if -6.79999999999999955e127 < y < -8.80000000000000026e38 or -1.3500000000000001e-21 < y < 2.60000000000000003e145Initial program 99.3%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 21.5%
*-commutative21.5%
associate-/r*21.5%
div-sub21.5%
rec-exp21.5%
rec-exp21.5%
Simplified88.8%
if -8.80000000000000026e38 < y < -1.3500000000000001e-21Initial program 99.8%
Taylor expanded in t around 0 90.3%
Final simplification90.1%
(FPCore (x y z t) :precision binary64 (if (or (<= y -7e+127) (not (<= y 4e+145))) (+ x (* z (- t x))) (+ x (* (tanh (/ t y)) (* z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7e+127) || !(y <= 4e+145)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (tanh((t / y)) * (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 ((y <= (-7d+127)) .or. (.not. (y <= 4d+145))) then
tmp = x + (z * (t - x))
else
tmp = x + (tanh((t / y)) * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7e+127) || !(y <= 4e+145)) {
tmp = x + (z * (t - x));
} else {
tmp = x + (Math.tanh((t / y)) * (z * y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -7e+127) or not (y <= 4e+145): tmp = x + (z * (t - x)) else: tmp = x + (math.tanh((t / y)) * (z * y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -7e+127) || !(y <= 4e+145)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -7e+127) || ~((y <= 4e+145))) tmp = x + (z * (t - x)); else tmp = x + (tanh((t / y)) * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -7e+127], N[Not[LessEqual[y, 4e+145]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+127} \lor \neg \left(y \leq 4 \cdot 10^{+145}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -6.99999999999999956e127 or 4e145 < y Initial program 81.0%
associate-*l*83.8%
Simplified83.8%
Taylor expanded in y around inf 92.8%
if -6.99999999999999956e127 < y < 4e145Initial program 99.4%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 23.1%
*-commutative23.1%
associate-/r*23.1%
div-sub23.1%
rec-exp23.1%
rec-exp23.1%
Simplified86.5%
Final simplification88.4%
(FPCore (x y z t) :precision binary64 (if (<= x -1.02e+96) x (if (<= x -1.1e-113) (- x (* z x)) (if (<= x 6.5e-83) (+ x (* z t)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.02e+96) {
tmp = x;
} else if (x <= -1.1e-113) {
tmp = x - (z * x);
} else if (x <= 6.5e-83) {
tmp = x + (z * 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 (x <= (-1.02d+96)) then
tmp = x
else if (x <= (-1.1d-113)) then
tmp = x - (z * x)
else if (x <= 6.5d-83) then
tmp = x + (z * 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 (x <= -1.02e+96) {
tmp = x;
} else if (x <= -1.1e-113) {
tmp = x - (z * x);
} else if (x <= 6.5e-83) {
tmp = x + (z * t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.02e+96: tmp = x elif x <= -1.1e-113: tmp = x - (z * x) elif x <= 6.5e-83: tmp = x + (z * t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.02e+96) tmp = x; elseif (x <= -1.1e-113) tmp = Float64(x - Float64(z * x)); elseif (x <= 6.5e-83) tmp = Float64(x + Float64(z * t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.02e+96) tmp = x; elseif (x <= -1.1e-113) tmp = x - (z * x); elseif (x <= 6.5e-83) tmp = x + (z * t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.02e+96], x, If[LessEqual[x, -1.1e-113], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.5e-83], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{+96}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-113}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-83}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.02000000000000001e96 or 6.5e-83 < x Initial program 98.5%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in x around 0 35.8%
*-commutative35.8%
associate-/r*35.8%
div-sub35.8%
rec-exp35.8%
rec-exp35.8%
Simplified85.7%
Taylor expanded in x around inf 80.4%
if -1.02000000000000001e96 < x < -1.10000000000000002e-113Initial program 93.4%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in y around inf 66.6%
Taylor expanded in x around inf 67.2%
distribute-rgt1-in67.2%
associate-*r*67.2%
mul-1-neg67.2%
unsub-neg67.2%
Simplified67.2%
if -1.10000000000000002e-113 < x < 6.5e-83Initial program 87.9%
associate-*l*88.2%
Simplified88.2%
Taylor expanded in x around 0 15.0%
*-commutative15.0%
associate-/r*15.0%
div-sub15.0%
rec-exp15.0%
rec-exp15.0%
Simplified76.7%
Taylor expanded in y around inf 56.3%
Final simplification69.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.45e-73) (not (<= y 1.5e-33))) (+ x (* z (- t x))) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.45e-73) || !(y <= 1.5e-33)) {
tmp = x + (z * (t - x));
} 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 ((y <= (-1.45d-73)) .or. (.not. (y <= 1.5d-33))) then
tmp = x + (z * (t - x))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.45e-73) || !(y <= 1.5e-33)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.45e-73) or not (y <= 1.5e-33): tmp = x + (z * (t - x)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.45e-73) || !(y <= 1.5e-33)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.45e-73) || ~((y <= 1.5e-33))) tmp = x + (z * (t - x)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.45e-73], N[Not[LessEqual[y, 1.5e-33]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-73} \lor \neg \left(y \leq 1.5 \cdot 10^{-33}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.45e-73 or 1.5000000000000001e-33 < y Initial program 90.3%
associate-*l*92.2%
Simplified92.2%
Taylor expanded in y around inf 75.5%
if -1.45e-73 < y < 1.5000000000000001e-33Initial program 100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around 0 18.8%
*-commutative18.8%
associate-/r*18.8%
div-sub18.8%
rec-exp18.8%
rec-exp18.8%
Simplified89.2%
Taylor expanded in x around inf 81.2%
Final simplification77.7%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.7e+119) (not (<= z 4.9e+132))) (* z (- t x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.7e+119) || !(z <= 4.9e+132)) {
tmp = z * (t - x);
} 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 <= (-1.7d+119)) .or. (.not. (z <= 4.9d+132))) then
tmp = z * (t - x)
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 <= -1.7e+119) || !(z <= 4.9e+132)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.7e+119) or not (z <= 4.9e+132): tmp = z * (t - x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.7e+119) || !(z <= 4.9e+132)) tmp = Float64(z * Float64(t - x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.7e+119) || ~((z <= 4.9e+132))) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.7e+119], N[Not[LessEqual[z, 4.9e+132]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+119} \lor \neg \left(z \leq 4.9 \cdot 10^{+132}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.70000000000000007e119 or 4.9000000000000002e132 < z Initial program 89.1%
associate-*l*95.5%
Simplified95.5%
Taylor expanded in y around inf 56.4%
Taylor expanded in z around inf 56.4%
if -1.70000000000000007e119 < z < 4.9000000000000002e132Initial program 96.2%
associate-*l*95.0%
Simplified95.0%
Taylor expanded in x around 0 36.3%
*-commutative36.3%
associate-/r*36.3%
div-sub36.3%
rec-exp36.3%
rec-exp36.3%
Simplified92.4%
Taylor expanded in x around inf 74.1%
Final simplification68.5%
(FPCore (x y z t) :precision binary64 (if (<= x -1.75e-47) x (if (<= x 4.9e-82) (+ x (* z t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.75e-47) {
tmp = x;
} else if (x <= 4.9e-82) {
tmp = x + (z * 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 (x <= (-1.75d-47)) then
tmp = x
else if (x <= 4.9d-82) then
tmp = x + (z * 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 (x <= -1.75e-47) {
tmp = x;
} else if (x <= 4.9e-82) {
tmp = x + (z * t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.75e-47: tmp = x elif x <= 4.9e-82: tmp = x + (z * t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.75e-47) tmp = x; elseif (x <= 4.9e-82) tmp = Float64(x + Float64(z * t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.75e-47) tmp = x; elseif (x <= 4.9e-82) tmp = x + (z * t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.75e-47], x, If[LessEqual[x, 4.9e-82], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-47}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{-82}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.7499999999999999e-47 or 4.9000000000000003e-82 < x Initial program 98.2%
associate-*l*99.4%
Simplified99.4%
Taylor expanded in x around 0 33.7%
*-commutative33.7%
associate-/r*33.7%
div-sub33.7%
rec-exp33.7%
rec-exp33.7%
Simplified84.1%
Taylor expanded in x around inf 77.1%
if -1.7499999999999999e-47 < x < 4.9000000000000003e-82Initial program 87.6%
associate-*l*88.8%
Simplified88.8%
Taylor expanded in x around 0 15.7%
*-commutative15.7%
associate-/r*15.7%
div-sub15.7%
rec-exp15.7%
rec-exp15.7%
Simplified75.2%
Taylor expanded in y around inf 54.4%
Final simplification68.0%
(FPCore (x y z t) :precision binary64 (if (<= x -1.05e-105) x (if (<= x 4.2e-254) (* z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.05e-105) {
tmp = x;
} else if (x <= 4.2e-254) {
tmp = z * 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 (x <= (-1.05d-105)) then
tmp = x
else if (x <= 4.2d-254) then
tmp = z * 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 (x <= -1.05e-105) {
tmp = x;
} else if (x <= 4.2e-254) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.05e-105: tmp = x elif x <= 4.2e-254: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.05e-105) tmp = x; elseif (x <= 4.2e-254) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.05e-105) tmp = x; elseif (x <= 4.2e-254) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.05e-105], x, If[LessEqual[x, 4.2e-254], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{-105}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-254}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.05e-105 or 4.19999999999999993e-254 < x Initial program 95.7%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in x around 0 31.5%
*-commutative31.5%
associate-/r*31.5%
div-sub31.5%
rec-exp31.5%
rec-exp31.5%
Simplified80.0%
Taylor expanded in x around inf 68.9%
if -1.05e-105 < x < 4.19999999999999993e-254Initial program 87.7%
associate-*l*88.2%
Simplified88.2%
Taylor expanded in x around 0 8.9%
*-commutative8.9%
associate-/r*8.9%
div-sub8.9%
rec-exp8.9%
rec-exp8.9%
Simplified82.1%
Taylor expanded in y around inf 56.1%
Taylor expanded in t around inf 49.7%
Final simplification64.6%
(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 93.9%
associate-*l*95.1%
Simplified95.1%
Taylor expanded in x around 0 26.5%
*-commutative26.5%
associate-/r*26.5%
div-sub26.5%
rec-exp26.5%
rec-exp26.5%
Simplified80.5%
Taylor expanded in x around inf 56.9%
Final simplification56.9%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
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 * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2023185
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:herbie-target
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))