
(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 10 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
(let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* z y)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 1e+305)))
(+ x (* z (- t x)))
t_1)))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 1e+305)) {
tmp = x + (z * (t - x));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (z * y));
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 1e+305)) {
tmp = x + (z * (t - x));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (z * y)) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 1e+305): tmp = x + (z * (t - x)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(z * y))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 1e+305)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y)); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 1e+305))) tmp = x + (z * (t - x)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 1e+305]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 10^{+305}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 9.9999999999999994e304 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 48.5%
Taylor expanded in y around inf 100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 9.9999999999999994e304Initial program 99.3%
Final simplification99.4%
(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 91.6%
+-commutative91.6%
*-commutative91.6%
associate-*l*98.0%
fma-def98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (if (<= y 2e+188) (+ 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 <= 2e+188) {
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 <= 2d+188) 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 <= 2e+188) {
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 <= 2e+188: 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 <= 2e+188) 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 <= 2e+188) 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, 2e+188], 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 \cdot 10^{+188}:\\
\;\;\;\;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 < 2e188Initial program 94.4%
add-log-exp60.5%
associate-*l*60.5%
exp-prod59.0%
Applied egg-rr59.0%
log-pow52.0%
rem-log-exp98.6%
Simplified98.6%
if 2e188 < y Initial program 66.7%
Taylor expanded in y around inf 98.0%
Final simplification98.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (tanh (/ t y))))) (if (<= y 5.1e+42) (fma z t_1 x) (+ x (* z (- t_1 x))))))
double code(double x, double y, double z, double t) {
double t_1 = y * tanh((t / y));
double tmp;
if (y <= 5.1e+42) {
tmp = fma(z, t_1, x);
} else {
tmp = x + (z * (t_1 - x));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * tanh(Float64(t / y))) tmp = 0.0 if (y <= 5.1e+42) tmp = fma(z, t_1, x); else tmp = Float64(x + Float64(z * Float64(t_1 - x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 5.1e+42], N[(z * t$95$1 + x), $MachinePrecision], N[(x + N[(z * N[(t$95$1 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 5.1 \cdot 10^{+42}:\\
\;\;\;\;\mathsf{fma}\left(z, t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t_1 - x\right)\\
\end{array}
\end{array}
if y < 5.0999999999999999e42Initial program 95.6%
+-commutative95.6%
*-commutative95.6%
associate-*l*99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in x around 0 23.7%
associate-/r*23.5%
rec-exp23.5%
div-sub23.5%
rec-exp23.5%
tanh-def-a79.1%
Simplified79.9%
if 5.0999999999999999e42 < y Initial program 75.9%
add-log-exp45.0%
associate-*l*45.2%
exp-prod35.8%
Applied egg-rr35.8%
log-pow19.9%
rem-log-exp88.8%
Simplified88.8%
Taylor expanded in x around 0 32.1%
associate--l+54.2%
mul-1-neg54.2%
distribute-frac-neg54.2%
associate-/r*54.2%
rec-exp54.2%
div-sub54.2%
rec-exp54.2%
tanh-def-a82.4%
Simplified82.4%
Taylor expanded in x around 0 57.9%
+-commutative57.9%
mul-1-neg57.9%
*-commutative57.9%
unsub-neg57.9%
Simplified63.3%
Taylor expanded in z around 0 57.9%
associate-/r*57.9%
div-sub57.9%
rec-exp57.9%
rec-exp57.9%
tanh-def-a89.9%
Simplified89.9%
Final simplification81.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 3.6e+42) (+ x (* t_1 (* z y))) (+ x (* z (- (* y t_1) x))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 3.6e+42) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (z * ((y * t_1) - 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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 3.6d+42) then
tmp = x + (t_1 * (z * y))
else
tmp = x + (z * ((y * t_1) - x))
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 <= 3.6e+42) {
tmp = x + (t_1 * (z * y));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 3.6e+42: tmp = x + (t_1 * (z * y)) else: tmp = x + (z * ((y * t_1) - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 3.6e+42) tmp = Float64(x + Float64(t_1 * Float64(z * y))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 3.6e+42) tmp = x + (t_1 * (z * y)); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 3.6e+42], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 3.6 \cdot 10^{+42}:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 3.6000000000000001e42Initial program 95.6%
Taylor expanded in x around 0 23.5%
associate-/r*23.5%
rec-exp23.5%
div-sub23.5%
rec-exp23.5%
tanh-def-a79.1%
Simplified79.1%
if 3.6000000000000001e42 < y Initial program 75.9%
add-log-exp45.0%
associate-*l*45.2%
exp-prod35.8%
Applied egg-rr35.8%
log-pow19.9%
rem-log-exp88.8%
Simplified88.8%
Taylor expanded in x around 0 32.1%
associate--l+54.2%
mul-1-neg54.2%
distribute-frac-neg54.2%
associate-/r*54.2%
rec-exp54.2%
div-sub54.2%
rec-exp54.2%
tanh-def-a82.4%
Simplified82.4%
Taylor expanded in x around 0 57.9%
+-commutative57.9%
mul-1-neg57.9%
*-commutative57.9%
unsub-neg57.9%
Simplified63.3%
Taylor expanded in z around 0 57.9%
associate-/r*57.9%
div-sub57.9%
rec-exp57.9%
rec-exp57.9%
tanh-def-a89.9%
Simplified89.9%
Final simplification81.3%
(FPCore (x y z t) :precision binary64 (if (<= y 2.5e+63) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.5e+63) {
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 <= 2.5d+63) 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 <= 2.5e+63) {
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 <= 2.5e+63: 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 <= 2.5e+63) 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 <= 2.5e+63) 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, 2.5e+63], 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 2.5 \cdot 10^{+63}:\\
\;\;\;\;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 < 2.50000000000000005e63Initial program 95.6%
Taylor expanded in x around 0 23.7%
associate-/r*23.7%
rec-exp23.7%
div-sub23.7%
rec-exp23.7%
tanh-def-a79.4%
Simplified79.4%
if 2.50000000000000005e63 < y Initial program 74.5%
Taylor expanded in y around inf 87.8%
Final simplification81.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.36e+42) x (if (<= y 1.85e+211) (* x (- 1.0 z)) (+ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.36e+42) {
tmp = x;
} else if (y <= 1.85e+211) {
tmp = x * (1.0 - z);
} 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.36d+42) then
tmp = x
else if (y <= 1.85d+211) then
tmp = x * (1.0d0 - z)
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.36e+42) {
tmp = x;
} else if (y <= 1.85e+211) {
tmp = x * (1.0 - z);
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.36e+42: tmp = x elif y <= 1.85e+211: tmp = x * (1.0 - z) else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.36e+42) tmp = x; elseif (y <= 1.85e+211) tmp = Float64(x * Float64(1.0 - z)); 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.36e+42) tmp = x; elseif (y <= 1.85e+211) tmp = x * (1.0 - z); else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.36e+42], x, If[LessEqual[y, 1.85e+211], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.36 \cdot 10^{+42}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+211}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.35999999999999999e42Initial program 95.6%
Taylor expanded in y around inf 54.9%
Taylor expanded in z around 0 66.3%
if 1.35999999999999999e42 < y < 1.85000000000000005e211Initial program 81.3%
Taylor expanded in y around inf 82.4%
Taylor expanded in x around inf 68.5%
mul-1-neg68.5%
unsub-neg68.5%
Simplified68.5%
if 1.85000000000000005e211 < y Initial program 68.0%
Taylor expanded in y around inf 97.5%
Taylor expanded in t around inf 86.5%
*-commutative86.5%
Simplified86.5%
Final simplification68.2%
(FPCore (x y z t) :precision binary64 (if (<= y 4.5e+39) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.5e+39) {
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 <= 4.5d+39) 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 <= 4.5e+39) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.5e+39: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.5e+39) 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 <= 4.5e+39) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.5e+39], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.49999999999999996e39Initial program 95.6%
Taylor expanded in y around inf 54.9%
Taylor expanded in z around 0 66.3%
if 4.49999999999999996e39 < y Initial program 75.9%
Taylor expanded in y around inf 88.5%
Final simplification70.8%
(FPCore (x y z t) :precision binary64 (if (<= y 5.5e+39) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.5e+39) {
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 <= 5.5d+39) 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 <= 5.5e+39) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.5e+39: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.5e+39) 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 <= 5.5e+39) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.5e+39], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 5.4999999999999997e39Initial program 95.6%
Taylor expanded in y around inf 54.9%
Taylor expanded in z around 0 66.3%
if 5.4999999999999997e39 < y Initial program 75.9%
Taylor expanded in y around inf 88.5%
Taylor expanded in x around inf 59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
Final simplification64.9%
(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 91.6%
Taylor expanded in y around inf 61.7%
Taylor expanded in z around 0 59.8%
Final simplification59.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 2023334
(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))))))