
(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 y (* z (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(y, (z * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(y, Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(y * N[(z * 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(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 95.1%
+-commutative95.1%
associate-*l*97.7%
fma-def97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -2.05e-52)
(+ x (* y (* z t_1)))
(if (<= t 8.5e-184)
(fma y (* z (- (/ t y) (tanh (/ x y)))) x)
(+ x (* t_1 (* y z)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -2.05e-52) {
tmp = x + (y * (z * t_1));
} else if (t <= 8.5e-184) {
tmp = fma(y, (z * ((t / y) - tanh((x / y)))), x);
} else {
tmp = x + (t_1 * (y * z));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -2.05e-52) tmp = Float64(x + Float64(y * Float64(z * t_1))); elseif (t <= 8.5e-184) tmp = fma(y, Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))), x); else tmp = Float64(x + Float64(t_1 * Float64(y * z))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -2.05e-52], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 8.5e-184], N[(y * N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -2.05 \cdot 10^{-52}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\
\mathbf{elif}\;t \leq 8.5 \cdot 10^{-184}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t_1 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if t < -2.04999999999999994e-52Initial program 96.7%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 7.4%
associate-/r*7.4%
div-sub7.4%
rec-exp7.4%
rec-exp7.4%
tanh-def-a90.6%
Simplified90.6%
if -2.04999999999999994e-52 < t < 8.50000000000000036e-184Initial program 89.8%
+-commutative89.8%
associate-*l*94.8%
fma-def94.9%
Simplified94.9%
Taylor expanded in t around 0 88.6%
if 8.50000000000000036e-184 < t Initial program 97.9%
associate-*l*98.0%
Simplified98.0%
Taylor expanded in x around 0 14.5%
*-commutative14.5%
Simplified82.3%
Final simplification86.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}
Initial program 95.1%
associate-*l*97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x y z t) :precision binary64 (if (<= y 8.2e+157) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e+157) {
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 <= 8.2d+157) 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 <= 8.2e+157) {
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 <= 8.2e+157: 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 <= 8.2e+157) 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 <= 8.2e+157) 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, 8.2e+157], 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 8.2 \cdot 10^{+157}:\\
\;\;\;\;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 < 8.20000000000000032e157Initial program 97.4%
associate-*l*98.7%
Simplified98.7%
Taylor expanded in x around 0 23.4%
associate-/r*23.4%
div-sub23.4%
rec-exp23.4%
rec-exp23.4%
tanh-def-a81.9%
Simplified81.9%
if 8.20000000000000032e157 < y Initial program 75.4%
associate-*l*89.1%
Simplified89.1%
Taylor expanded in y around inf 93.1%
Final simplification83.1%
(FPCore (x y z t) :precision binary64 (if (<= y 8.2e+157) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e+157) {
tmp = x + (tanh((t / y)) * (y * z));
} 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 <= 8.2d+157) then
tmp = x + (tanh((t / y)) * (y * z))
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 <= 8.2e+157) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.2e+157: tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.2e+157) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); 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 <= 8.2e+157) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.2e+157], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{+157}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 8.20000000000000032e157Initial program 97.4%
associate-*l*98.7%
Simplified98.7%
Taylor expanded in x around 0 23.4%
*-commutative23.4%
Simplified82.7%
if 8.20000000000000032e157 < y Initial program 75.4%
associate-*l*89.1%
Simplified89.1%
Taylor expanded in y around inf 93.1%
Final simplification83.8%
(FPCore (x y z t) :precision binary64 (if (<= y 1e+117) x (if (<= y 4.4e+174) (* x (- 1.0 z)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1e+117) {
tmp = x;
} else if (y <= 4.4e+174) {
tmp = x * (1.0 - z);
} else {
tmp = 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 <= 1d+117) then
tmp = x
else if (y <= 4.4d+174) then
tmp = x * (1.0d0 - z)
else
tmp = 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 <= 1e+117) {
tmp = x;
} else if (y <= 4.4e+174) {
tmp = x * (1.0 - z);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1e+117: tmp = x elif y <= 4.4e+174: tmp = x * (1.0 - z) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1e+117) tmp = x; elseif (y <= 4.4e+174) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1e+117) tmp = x; elseif (y <= 4.4e+174) tmp = x * (1.0 - z); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1e+117], x, If[LessEqual[y, 4.4e+174], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+117}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+174}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.00000000000000005e117Initial program 97.3%
+-commutative97.3%
associate-*l*99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in y around 0 61.2%
if 1.00000000000000005e117 < y < 4.40000000000000039e174Initial program 86.8%
associate-*l*93.4%
Simplified93.4%
Taylor expanded in y around inf 79.9%
Taylor expanded in x around inf 54.3%
neg-mul-154.3%
unsub-neg54.3%
Simplified54.3%
if 4.40000000000000039e174 < y Initial program 77.2%
associate-*l*85.9%
Simplified85.9%
Taylor expanded in y around inf 91.1%
Taylor expanded in z around inf 77.4%
Final simplification62.1%
(FPCore (x y z t) :precision binary64 (if (<= y 6.5e-94) x (if (<= y 3.45e+276) (+ x (* z t)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e-94) {
tmp = x;
} else if (y <= 3.45e+276) {
tmp = x + (z * t);
} else {
tmp = 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-94) then
tmp = x
else if (y <= 3.45d+276) then
tmp = x + (z * t)
else
tmp = 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-94) {
tmp = x;
} else if (y <= 3.45e+276) {
tmp = x + (z * t);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.5e-94: tmp = x elif y <= 3.45e+276: tmp = x + (z * t) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.5e-94) tmp = x; elseif (y <= 3.45e+276) tmp = Float64(x + Float64(z * t)); else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 6.5e-94) tmp = x; elseif (y <= 3.45e+276) tmp = x + (z * t); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.5e-94], x, If[LessEqual[y, 3.45e+276], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-94}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.45 \cdot 10^{+276}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 6.4999999999999996e-94Initial program 97.7%
+-commutative97.7%
associate-*l*99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in y around 0 65.1%
if 6.4999999999999996e-94 < y < 3.44999999999999982e276Initial program 90.4%
associate-*l*95.0%
Simplified95.0%
Taylor expanded in x around 0 23.3%
*-commutative23.3%
Simplified75.3%
Taylor expanded in t around 0 56.3%
+-commutative56.3%
Simplified56.3%
if 3.44999999999999982e276 < y Initial program 85.7%
associate-*l*86.0%
Simplified86.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 100.0%
Final simplification63.4%
(FPCore (x y z t) :precision binary64 (if (<= y 7.4e+73) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.4e+73) {
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 <= 7.4d+73) 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 <= 7.4e+73) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7.4e+73: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7.4e+73) 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 <= 7.4e+73) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.4e+73], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.4 \cdot 10^{+73}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 7.39999999999999947e73Initial program 97.6%
+-commutative97.6%
associate-*l*99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in y around 0 62.7%
if 7.39999999999999947e73 < y Initial program 85.4%
associate-*l*90.7%
Simplified90.7%
Taylor expanded in y around inf 79.6%
Final simplification66.1%
(FPCore (x y z t) :precision binary64 (if (<= y 1.2e+117) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.2e+117) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
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.2d+117) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.2e+117) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.2e+117: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.2e+117) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.2e+117) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.2e+117], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+117}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 1.1999999999999999e117Initial program 97.3%
+-commutative97.3%
associate-*l*99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in y around 0 61.2%
if 1.1999999999999999e117 < y Initial program 81.0%
associate-*l*88.9%
Simplified88.9%
Taylor expanded in y around inf 86.6%
Taylor expanded in x around inf 48.3%
neg-mul-148.3%
unsub-neg48.3%
Simplified48.3%
Final simplification59.4%
(FPCore (x y z t) :precision binary64 (if (<= y 2.65e+276) x (* z (- x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.65e+276) {
tmp = x;
} else {
tmp = 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 <= 2.65d+276) then
tmp = x
else
tmp = z * -x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.65e+276) {
tmp = x;
} else {
tmp = z * -x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.65e+276: tmp = x else: tmp = z * -x return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.65e+276) tmp = x; else tmp = Float64(z * Float64(-x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.65e+276) tmp = x; else tmp = z * -x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.65e+276], x, N[(z * (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.65 \cdot 10^{+276}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\end{array}
\end{array}
if y < 2.64999999999999998e276Initial program 95.4%
+-commutative95.4%
associate-*l*98.0%
fma-def98.0%
Simplified98.0%
Taylor expanded in y around 0 57.8%
if 2.64999999999999998e276 < y Initial program 85.7%
associate-*l*86.0%
Simplified86.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around inf 58.0%
neg-mul-158.0%
unsub-neg58.0%
Simplified58.0%
Taylor expanded in z around inf 58.0%
mul-1-neg58.0%
*-commutative58.0%
distribute-rgt-neg-in58.0%
Simplified58.0%
Final simplification57.8%
(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.1%
+-commutative95.1%
associate-*l*97.7%
fma-def97.7%
Simplified97.7%
Taylor expanded in y around 0 56.2%
Final simplification56.2%
(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 2023308
(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))))))