
(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 12 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 95.4%
+-commutative95.4%
*-commutative95.4%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Final simplification98.1%
(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 95.4%
associate-*l*97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -4.2e-75) (not (<= t 6e-28))) (fma z (* y (tanh (/ t y))) x) (+ x (* (* z y) (- (/ t y) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.2e-75) || !(t <= 6e-28)) {
tmp = fma(z, (y * tanh((t / y))), x);
} else {
tmp = x + ((z * y) * ((t / y) - tanh((x / y))));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -4.2e-75) || !(t <= 6e-28)) tmp = fma(z, Float64(y * tanh(Float64(t / y))), x); else tmp = Float64(x + Float64(Float64(z * y) * Float64(Float64(t / y) - tanh(Float64(x / y))))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -4.2e-75], N[Not[LessEqual[t, 6e-28]], $MachinePrecision]], N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(N[(z * y), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.2 \cdot 10^{-75} \lor \neg \left(t \leq 6 \cdot 10^{-28}\right):\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \tanh \left(\frac{t}{y}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -4.2000000000000002e-75 or 6.00000000000000005e-28 < t Initial program 96.6%
+-commutative96.6%
*-commutative96.6%
associate-*l*99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in x around 0 9.9%
associate-/r*9.9%
div-sub9.8%
rec-exp9.8%
rec-exp9.8%
tanh-def-a90.9%
Simplified90.9%
if -4.2000000000000002e-75 < t < 6.00000000000000005e-28Initial program 93.8%
Taylor expanded in t around 0 90.6%
Final simplification90.8%
(FPCore (x y z t) :precision binary64 (if (or (<= t -7e-74) (not (<= t 1.15e-28))) (+ x (* y (* z (tanh (/ t y))))) (+ x (* (* z y) (- (/ t y) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7e-74) || !(t <= 1.15e-28)) {
tmp = x + (y * (z * tanh((t / y))));
} else {
tmp = x + ((z * y) * ((t / y) - tanh((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) :: tmp
if ((t <= (-7d-74)) .or. (.not. (t <= 1.15d-28))) then
tmp = x + (y * (z * tanh((t / y))))
else
tmp = x + ((z * y) * ((t / y) - tanh((x / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7e-74) || !(t <= 1.15e-28)) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + ((z * y) * ((t / y) - Math.tanh((x / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -7e-74) or not (t <= 1.15e-28): tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + ((z * y) * ((t / y) - math.tanh((x / y)))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -7e-74) || !(t <= 1.15e-28)) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(Float64(z * y) * Float64(Float64(t / y) - tanh(Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -7e-74) || ~((t <= 1.15e-28))) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + ((z * y) * ((t / y) - tanh((x / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -7e-74], N[Not[LessEqual[t, 1.15e-28]], $MachinePrecision]], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z * y), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7 \cdot 10^{-74} \lor \neg \left(t \leq 1.15 \cdot 10^{-28}\right):\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -7.00000000000000029e-74 or 1.14999999999999993e-28 < t Initial program 96.6%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around 0 9.9%
*-commutative9.9%
associate-/r*9.9%
div-sub9.8%
rec-exp9.8%
rec-exp9.8%
tanh-def-a90.2%
Simplified90.2%
if -7.00000000000000029e-74 < t < 1.14999999999999993e-28Initial program 93.8%
Taylor expanded in t around 0 90.6%
Final simplification90.4%
(FPCore (x y z t) :precision binary64 (if (<= y 3.5e+192) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e+192) {
tmp = x + (y * (z * tanh((t / 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 <= 3.5d+192) then
tmp = x + (y * (z * tanh((t / 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 <= 3.5e+192) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.5e+192: tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.5e+192) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / 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 <= 3.5e+192) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.5e+192], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $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 3.5 \cdot 10^{+192}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.49999999999999983e192Initial program 96.3%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 25.8%
*-commutative25.8%
associate-/r*25.9%
div-sub25.8%
rec-exp25.8%
rec-exp25.8%
tanh-def-a81.7%
Simplified81.7%
if 3.49999999999999983e192 < y Initial program 82.8%
+-commutative82.8%
*-commutative82.8%
associate-*l*94.2%
fma-def94.2%
Simplified94.2%
Taylor expanded in y around inf 94.8%
Final simplification82.6%
(FPCore (x y z t) :precision binary64 (if (<= y 1.25e-38) x (fma (- t x) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e-38) {
tmp = x;
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.25e-38) tmp = x; else tmp = fma(Float64(t - x), z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.25e-38], x, N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{-38}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 1.25000000000000008e-38Initial program 96.0%
+-commutative96.0%
*-commutative96.0%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in z around 0 64.1%
if 1.25000000000000008e-38 < y Initial program 93.4%
+-commutative93.4%
*-commutative93.4%
associate-*l*96.7%
fma-def96.7%
Simplified96.7%
Taylor expanded in y around inf 71.8%
fma-def71.8%
Simplified71.8%
Final simplification65.9%
(FPCore (x y z t)
:precision binary64
(if (or (<= z -1.25e+119)
(and (not (<= z 1.4e-29)) (or (<= z 2.8e+61) (not (<= z 2.6e+118)))))
(* z (- t x))
x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.25e+119) || (!(z <= 1.4e-29) && ((z <= 2.8e+61) || !(z <= 2.6e+118)))) {
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.25d+119)) .or. (.not. (z <= 1.4d-29)) .and. (z <= 2.8d+61) .or. (.not. (z <= 2.6d+118))) 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.25e+119) || (!(z <= 1.4e-29) && ((z <= 2.8e+61) || !(z <= 2.6e+118)))) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.25e+119) or (not (z <= 1.4e-29) and ((z <= 2.8e+61) or not (z <= 2.6e+118))): tmp = z * (t - x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.25e+119) || (!(z <= 1.4e-29) && ((z <= 2.8e+61) || !(z <= 2.6e+118)))) 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.25e+119) || (~((z <= 1.4e-29)) && ((z <= 2.8e+61) || ~((z <= 2.6e+118))))) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.25e+119], And[N[Not[LessEqual[z, 1.4e-29]], $MachinePrecision], Or[LessEqual[z, 2.8e+61], N[Not[LessEqual[z, 2.6e+118]], $MachinePrecision]]]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+119} \lor \neg \left(z \leq 1.4 \cdot 10^{-29}\right) \land \left(z \leq 2.8 \cdot 10^{+61} \lor \neg \left(z \leq 2.6 \cdot 10^{+118}\right)\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.25e119 or 1.4000000000000001e-29 < z < 2.8000000000000001e61 or 2.60000000000000016e118 < z Initial program 89.9%
+-commutative89.9%
*-commutative89.9%
associate-*l*95.4%
fma-def95.4%
Simplified95.4%
Taylor expanded in y around inf 50.8%
Taylor expanded in z around inf 49.5%
if -1.25e119 < z < 1.4000000000000001e-29 or 2.8000000000000001e61 < z < 2.60000000000000016e118Initial program 98.2%
+-commutative98.2%
*-commutative98.2%
associate-*l*99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in z around 0 77.0%
Final simplification67.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.26e-40) x (+ x (- (* z t) (* z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.26e-40) {
tmp = x;
} else {
tmp = x + ((z * t) - (z * 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.26d-40) then
tmp = x
else
tmp = x + ((z * t) - (z * x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.26e-40) {
tmp = x;
} else {
tmp = x + ((z * t) - (z * x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.26e-40: tmp = x else: tmp = x + ((z * t) - (z * x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.26e-40) tmp = x; else tmp = Float64(x + Float64(Float64(z * t) - Float64(z * x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.26e-40) tmp = x; else tmp = x + ((z * t) - (z * x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.26e-40], x, N[(x + N[(N[(z * t), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.26 \cdot 10^{-40}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot t - z \cdot x\right)\\
\end{array}
\end{array}
if y < 1.26e-40Initial program 96.0%
+-commutative96.0%
*-commutative96.0%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in z around 0 64.1%
if 1.26e-40 < y Initial program 93.4%
associate-*l*96.6%
Simplified96.6%
Taylor expanded in x around 0 46.0%
*-commutative46.0%
mul-1-neg46.0%
unsub-neg46.0%
Simplified83.1%
Taylor expanded in y around inf 71.8%
*-commutative71.8%
Simplified71.8%
Final simplification65.9%
(FPCore (x y z t) :precision binary64 (if (<= t -1.6e-254) x (if (<= t 4.2e+156) (* x (- 1.0 z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.6e-254) {
tmp = x;
} else if (t <= 4.2e+156) {
tmp = x * (1.0 - 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 (t <= (-1.6d-254)) then
tmp = x
else if (t <= 4.2d+156) then
tmp = x * (1.0d0 - 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 (t <= -1.6e-254) {
tmp = x;
} else if (t <= 4.2e+156) {
tmp = x * (1.0 - z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.6e-254: tmp = x elif t <= 4.2e+156: tmp = x * (1.0 - z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.6e-254) tmp = x; elseif (t <= 4.2e+156) tmp = Float64(x * Float64(1.0 - z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.6e-254) tmp = x; elseif (t <= 4.2e+156) tmp = x * (1.0 - z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.6e-254], x, If[LessEqual[t, 4.2e+156], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.6 \cdot 10^{-254}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 4.2 \cdot 10^{+156}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.6e-254 or 4.19999999999999963e156 < t Initial program 96.7%
+-commutative96.7%
*-commutative96.7%
associate-*l*98.7%
fma-def98.7%
Simplified98.7%
Taylor expanded in z around 0 60.5%
if -1.6e-254 < t < 4.19999999999999963e156Initial program 93.5%
+-commutative93.5%
*-commutative93.5%
associate-*l*97.2%
fma-def97.2%
Simplified97.2%
Taylor expanded in y around inf 75.1%
Taylor expanded in x around inf 63.7%
Taylor expanded in z around 0 63.7%
+-commutative63.7%
mul-1-neg63.7%
unsub-neg63.7%
Simplified63.7%
Taylor expanded in x around 0 63.7%
Final simplification61.8%
(FPCore (x y z t) :precision binary64 (if (<= y 1.25e-38) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e-38) {
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 <= 1.25d-38) 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 <= 1.25e-38) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.25e-38: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.25e-38) 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 <= 1.25e-38) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.25e-38], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{-38}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.25000000000000008e-38Initial program 96.0%
+-commutative96.0%
*-commutative96.0%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in z around 0 64.1%
if 1.25000000000000008e-38 < y Initial program 93.4%
+-commutative93.4%
*-commutative93.4%
associate-*l*96.7%
fma-def96.7%
Simplified96.7%
Taylor expanded in y around inf 71.8%
Final simplification65.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1.25e-38) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e-38) {
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.25d-38) 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.25e-38) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.25e-38: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.25e-38) 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.25e-38) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.25e-38], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{-38}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.25000000000000008e-38Initial program 96.0%
+-commutative96.0%
*-commutative96.0%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in z around 0 64.1%
if 1.25000000000000008e-38 < y Initial program 93.4%
+-commutative93.4%
*-commutative93.4%
associate-*l*96.7%
fma-def96.7%
Simplified96.7%
Taylor expanded in x around 0 39.8%
associate-/r*39.8%
div-sub39.7%
rec-exp39.7%
rec-exp39.7%
tanh-def-a77.3%
Simplified77.3%
Taylor expanded in y around inf 65.6%
Final simplification64.4%
(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 95.4%
+-commutative95.4%
*-commutative95.4%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Taylor expanded in z around 0 58.8%
Final simplification58.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}
herbie shell --seed 2023214
(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))))))