
(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 (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 94.7%
+-commutative94.7%
*-commutative94.7%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Final simplification98.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -2.15e-54)
(fma z (* y t_1) x)
(if (<= t 3.9e-100)
(fma z (* y (- (/ t y) (tanh (/ x y)))) x)
(+ x (* t_1 (* z y)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -2.15e-54) {
tmp = fma(z, (y * t_1), x);
} else if (t <= 3.9e-100) {
tmp = fma(z, (y * ((t / y) - tanh((x / y)))), x);
} else {
tmp = x + (t_1 * (z * y));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -2.15e-54) tmp = fma(z, Float64(y * t_1), x); elseif (t <= 3.9e-100) tmp = fma(z, Float64(y * Float64(Float64(t / y) - tanh(Float64(x / y)))), x); else tmp = Float64(x + Float64(t_1 * Float64(z * y))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -2.15e-54], N[(z * N[(y * t$95$1), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 3.9e-100], N[(z * N[(y * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -2.15 \cdot 10^{-54}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\
\mathbf{elif}\;t \leq 3.9 \cdot 10^{-100}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if t < -2.15e-54Initial program 97.3%
+-commutative97.3%
*-commutative97.3%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 12.3%
associate-/r*12.3%
div-sub12.3%
rec-exp12.3%
rec-exp12.3%
tanh-def-a83.3%
Simplified83.3%
if -2.15e-54 < t < 3.89999999999999977e-100Initial program 90.1%
+-commutative90.1%
*-commutative90.1%
associate-*l*95.1%
fma-def95.1%
Simplified95.1%
Taylor expanded in t around 0 90.4%
if 3.89999999999999977e-100 < t Initial program 97.8%
associate-*l*98.8%
Simplified98.8%
Taylor expanded in x around 0 16.9%
*-commutative16.9%
associate-/r*16.9%
div-sub16.9%
rec-exp16.9%
rec-exp16.9%
tanh-def-a83.3%
Simplified85.6%
Final simplification86.8%
(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}
Initial program 94.7%
associate-*l*97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 7.2e+32) (fma z (* y t_1) x) (+ x (* y (* z (- t_1 (/ x y))))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 7.2e+32) {
tmp = fma(z, (y * t_1), x);
} else {
tmp = x + (y * (z * (t_1 - (x / y))));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 7.2e+32) tmp = fma(z, Float64(y * t_1), x); else tmp = Float64(x + Float64(y * Float64(z * Float64(t_1 - Float64(x / y))))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 7.2e+32], N[(z * N[(y * t$95$1), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(y * N[(z * N[(t$95$1 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 7.2 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(t_1 - \frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if y < 7.1999999999999994e32Initial program 96.1%
+-commutative96.1%
*-commutative96.1%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in x around 0 21.6%
associate-/r*21.6%
div-sub21.6%
rec-exp21.6%
rec-exp21.6%
tanh-def-a76.5%
Simplified76.5%
if 7.1999999999999994e32 < y Initial program 89.8%
associate-*l*93.3%
Simplified93.3%
Taylor expanded in x around 0 34.0%
associate--l+49.7%
associate-*r/49.7%
mul-1-neg49.7%
associate-/r*49.7%
div-sub49.7%
rec-exp49.7%
rec-exp49.7%
tanh-def-a86.8%
Simplified86.8%
Taylor expanded in z around 0 33.5%
*-commutative33.5%
mul-1-neg33.5%
distribute-frac-neg33.5%
+-commutative33.5%
distribute-frac-neg33.5%
mul-1-neg33.5%
associate-*r*34.0%
Simplified86.8%
Final simplification78.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 6.6e+32)
(+ x (* t_1 (* z y)))
(+ x (* y (* z (- t_1 (/ x y))))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 6.6e+32) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (y * (z * (t_1 - (x / 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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 6.6d+32) then
tmp = x + (t_1 * (z * y))
else
tmp = x + (y * (z * (t_1 - (x / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 6.6e+32) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (y * (z * (t_1 - (x / y))));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 6.6e+32: tmp = x + (t_1 * (z * y)) else: tmp = x + (y * (z * (t_1 - (x / y)))) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 6.6e+32) tmp = Float64(x + Float64(t_1 * Float64(z * y))); else tmp = Float64(x + Float64(y * Float64(z * Float64(t_1 - Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 6.6e+32) tmp = x + (t_1 * (z * y)); else tmp = x + (y * (z * (t_1 - (x / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 6.6e+32], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * N[(t$95$1 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 6.6 \cdot 10^{+32}:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(t_1 - \frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if y < 6.60000000000000039e32Initial program 96.1%
associate-*l*98.5%
Simplified98.5%
Taylor expanded in x around 0 21.6%
*-commutative21.6%
associate-/r*21.6%
div-sub21.6%
rec-exp21.6%
rec-exp21.6%
tanh-def-a76.5%
Simplified75.4%
if 6.60000000000000039e32 < y Initial program 89.8%
associate-*l*93.3%
Simplified93.3%
Taylor expanded in x around 0 34.0%
associate--l+49.7%
associate-*r/49.7%
mul-1-neg49.7%
associate-/r*49.7%
div-sub49.7%
rec-exp49.7%
rec-exp49.7%
tanh-def-a86.8%
Simplified86.8%
Taylor expanded in z around 0 33.5%
*-commutative33.5%
mul-1-neg33.5%
distribute-frac-neg33.5%
+-commutative33.5%
distribute-frac-neg33.5%
mul-1-neg33.5%
associate-*r*34.0%
Simplified86.8%
Final simplification78.0%
(FPCore (x y z t) :precision binary64 (if (<= y 6.5e+93) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e+93) {
tmp = x + (tanh((t / y)) * (z * 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 <= 6.5d+93) then
tmp = x + (tanh((t / y)) * (z * 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 <= 6.5e+93) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.5e+93: tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.5e+93) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * 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 <= 6.5e+93) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.5e+93], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+93}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 6.4999999999999998e93Initial program 95.9%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around 0 21.8%
*-commutative21.8%
associate-/r*21.8%
div-sub21.8%
rec-exp21.8%
rec-exp21.8%
tanh-def-a76.0%
Simplified75.5%
if 6.4999999999999998e93 < y Initial program 88.7%
+-commutative88.7%
*-commutative88.7%
associate-*l*95.6%
fma-def95.6%
Simplified95.6%
Taylor expanded in y around inf 89.2%
Final simplification77.9%
(FPCore (x y z t)
:precision binary64
(if (<= y 8.2e+32)
x
(if (or (<= y 4.1e+108) (not (<= y 6.6e+221)))
(- x (* z x))
(+ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e+32) {
tmp = x;
} else if ((y <= 4.1e+108) || !(y <= 6.6e+221)) {
tmp = x - (z * x);
} else {
tmp = x + (z * t);
}
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 <= 8.2d+32) then
tmp = x
else if ((y <= 4.1d+108) .or. (.not. (y <= 6.6d+221))) then
tmp = x - (z * x)
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e+32) {
tmp = x;
} else if ((y <= 4.1e+108) || !(y <= 6.6e+221)) {
tmp = x - (z * x);
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.2e+32: tmp = x elif (y <= 4.1e+108) or not (y <= 6.6e+221): tmp = x - (z * x) else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.2e+32) tmp = x; elseif ((y <= 4.1e+108) || !(y <= 6.6e+221)) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 8.2e+32) tmp = x; elseif ((y <= 4.1e+108) || ~((y <= 6.6e+221))) tmp = x - (z * x); else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.2e+32], x, If[Or[LessEqual[y, 4.1e+108], N[Not[LessEqual[y, 6.6e+221]], $MachinePrecision]], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{+32}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+108} \lor \neg \left(y \leq 6.6 \cdot 10^{+221}\right):\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 8.19999999999999961e32Initial program 96.1%
+-commutative96.1%
*-commutative96.1%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in z around 0 61.4%
if 8.19999999999999961e32 < y < 4.0999999999999999e108 or 6.59999999999999983e221 < y Initial program 90.2%
associate-*l*93.6%
Simplified93.6%
Taylor expanded in x around 0 36.5%
associate--l+58.0%
associate-*r/58.0%
mul-1-neg58.0%
associate-/r*58.0%
div-sub58.0%
rec-exp58.0%
rec-exp58.0%
tanh-def-a84.3%
Simplified84.3%
Taylor expanded in z around 0 36.0%
*-commutative36.0%
mul-1-neg36.0%
distribute-frac-neg36.0%
+-commutative36.0%
distribute-frac-neg36.0%
mul-1-neg36.0%
associate-*r*36.5%
Simplified84.3%
Taylor expanded in x around inf 64.9%
distribute-rgt1-in65.0%
associate-*r*65.0%
mul-1-neg65.0%
unsub-neg65.0%
*-commutative65.0%
Simplified65.0%
if 4.0999999999999999e108 < y < 6.59999999999999983e221Initial program 89.4%
+-commutative89.4%
*-commutative89.4%
associate-*l*96.5%
fma-def96.5%
Simplified96.5%
Taylor expanded in y around inf 86.3%
Taylor expanded in t around inf 79.6%
Final simplification63.8%
(FPCore (x y z t) :precision binary64 (if (<= y 5.4e-24) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.4e-24) {
tmp = x;
} 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 <= 5.4d-24) then
tmp = x
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 <= 5.4e-24) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.4e-24: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.4e-24) tmp = x; 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 <= 5.4e-24) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.4e-24], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.4 \cdot 10^{-24}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 5.40000000000000014e-24Initial program 95.9%
+-commutative95.9%
*-commutative95.9%
associate-*l*98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in z around 0 60.9%
if 5.40000000000000014e-24 < y Initial program 91.3%
+-commutative91.3%
*-commutative91.3%
associate-*l*97.1%
fma-def97.1%
Simplified97.1%
Taylor expanded in y around inf 79.1%
Final simplification65.8%
(FPCore (x y z t) :precision binary64 (if (<= x -3.4e-221) x (if (<= x 1.65e-166) (* z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -3.4e-221) {
tmp = x;
} else if (x <= 1.65e-166) {
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 <= (-3.4d-221)) then
tmp = x
else if (x <= 1.65d-166) 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 <= -3.4e-221) {
tmp = x;
} else if (x <= 1.65e-166) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -3.4e-221: tmp = x elif x <= 1.65e-166: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -3.4e-221) tmp = x; elseif (x <= 1.65e-166) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -3.4e-221) tmp = x; elseif (x <= 1.65e-166) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -3.4e-221], x, If[LessEqual[x, 1.65e-166], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4 \cdot 10^{-221}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-166}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.4000000000000001e-221 or 1.65000000000000009e-166 < x Initial program 96.6%
+-commutative96.6%
*-commutative96.6%
associate-*l*99.0%
fma-def99.0%
Simplified99.0%
Taylor expanded in z around 0 65.4%
if -3.4000000000000001e-221 < x < 1.65000000000000009e-166Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
associate-*l*94.7%
fma-def94.7%
Simplified94.7%
Taylor expanded in y around inf 58.6%
Taylor expanded in t around inf 53.0%
Taylor expanded in t around inf 44.9%
Final simplification61.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.02e-25) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.02e-25) {
tmp = x;
} else {
tmp = x + (z * t);
}
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.02d-25) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.02e-25) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.02e-25: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.02e-25) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.02e-25) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.02e-25], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{-25}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.01999999999999998e-25Initial program 95.9%
+-commutative95.9%
*-commutative95.9%
associate-*l*98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in z around 0 60.9%
if 1.01999999999999998e-25 < y Initial program 91.3%
+-commutative91.3%
*-commutative91.3%
associate-*l*97.1%
fma-def97.1%
Simplified97.1%
Taylor expanded in y around inf 79.1%
Taylor expanded in t around inf 65.5%
Final simplification62.2%
(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 94.7%
+-commutative94.7%
*-commutative94.7%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Taylor expanded in z around 0 56.4%
Final simplification56.4%
(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 2023240
(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))))))