
(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 9 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 4e+292)))
(+ 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 <= 4e+292)) {
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 <= 4e+292)) {
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 <= 4e+292): 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 <= 4e+292)) 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 <= 4e+292))) 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, 4e+292]], $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 4 \cdot 10^{+292}\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 4.0000000000000001e292 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 38.8%
Taylor expanded in y around inf 91.8%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.0000000000000001e292Initial program 99.5%
Final simplification98.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))) (t_2 (tanh (/ x y))))
(if (<= (+ x (* (- t_1 t_2) (* z y))) 4e+292)
(+ x (- (* y (* z t_1)) (* y (* z t_2))))
(+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double t_2 = tanh((x / y));
double tmp;
if ((x + ((t_1 - t_2) * (z * y))) <= 4e+292) {
tmp = x + ((y * (z * t_1)) - (y * (z * t_2)));
} 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = tanh((t / y))
t_2 = tanh((x / y))
if ((x + ((t_1 - t_2) * (z * y))) <= 4d+292) then
tmp = x + ((y * (z * t_1)) - (y * (z * t_2)))
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 t_1 = Math.tanh((t / y));
double t_2 = Math.tanh((x / y));
double tmp;
if ((x + ((t_1 - t_2) * (z * y))) <= 4e+292) {
tmp = x + ((y * (z * t_1)) - (y * (z * t_2)));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) t_2 = math.tanh((x / y)) tmp = 0 if (x + ((t_1 - t_2) * (z * y))) <= 4e+292: tmp = x + ((y * (z * t_1)) - (y * (z * t_2))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) t_2 = tanh(Float64(x / y)) tmp = 0.0 if (Float64(x + Float64(Float64(t_1 - t_2) * Float64(z * y))) <= 4e+292) tmp = Float64(x + Float64(Float64(y * Float64(z * t_1)) - Float64(y * Float64(z * t_2)))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); t_2 = tanh((x / y)); tmp = 0.0; if ((x + ((t_1 - t_2) * (z * y))) <= 4e+292) tmp = x + ((y * (z * t_1)) - (y * (z * t_2))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(t$95$1 - t$95$2), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+292], N[(x + N[(N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision] - N[(y * N[(z * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
t_2 := \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;x + \left(t_1 - t_2\right) \cdot \left(z \cdot y\right) \leq 4 \cdot 10^{+292}:\\
\;\;\;\;x + \left(y \cdot \left(z \cdot t_1\right) - y \cdot \left(z \cdot t_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.0000000000000001e292Initial program 96.0%
sub-neg96.0%
distribute-lft-in94.2%
Applied egg-rr94.2%
*-commutative94.2%
add-sqr-sqrt55.5%
sqrt-unprod88.2%
sqr-neg88.2%
sqrt-unprod42.9%
add-sqr-sqrt78.7%
cancel-sign-sub78.7%
associate-*l*78.3%
*-commutative78.3%
associate-*l*81.7%
add-sqr-sqrt48.1%
sqrt-unprod86.3%
sqr-neg86.3%
sqrt-unprod50.9%
add-sqr-sqrt99.1%
Applied egg-rr99.1%
if 4.0000000000000001e292 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 31.7%
Taylor expanded in y around inf 85.3%
Final simplification98.1%
(FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 90.9%
+-commutative90.9%
*-commutative90.9%
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 (<= y 0.94) (+ 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 <= 0.94) {
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 <= 0.94d0) 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 <= 0.94) {
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 <= 0.94: 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 <= 0.94) 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 <= 0.94) 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, 0.94], 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 0.94:\\
\;\;\;\;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 < 0.93999999999999995Initial program 95.0%
Taylor expanded in x around 0 22.2%
associate-*r*22.1%
associate-/r*22.1%
div-sub22.1%
rec-exp22.1%
rec-exp22.1%
tanh-def-a80.6%
Simplified80.6%
if 0.93999999999999995 < y Initial program 79.4%
Taylor expanded in x around 0 48.9%
+-commutative48.9%
Simplified82.7%
Taylor expanded in y around 0 48.9%
mul-1-neg48.9%
+-commutative48.9%
fma-def48.9%
Simplified82.7%
Final simplification81.2%
(FPCore (x y z t) :precision binary64 (if (<= y 6.2e+136) (+ 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.2e+136) {
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.2d+136) 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.2e+136) {
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.2e+136: 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.2e+136) 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.2e+136) 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.2e+136], 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.2 \cdot 10^{+136}:\\
\;\;\;\;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.19999999999999967e136Initial program 94.6%
Taylor expanded in x around 0 23.2%
associate-*r*23.1%
associate-/r*23.1%
div-sub23.1%
rec-exp23.1%
rec-exp23.1%
tanh-def-a80.3%
Simplified80.3%
if 6.19999999999999967e136 < y Initial program 71.6%
Taylor expanded in y around inf 84.5%
Final simplification80.9%
(FPCore (x y z t)
:precision binary64
(if (<= y 8.5e+29)
x
(if (or (<= y 2.8e+183) (not (<= y 1.35e+207)))
(+ x (* z t))
(* x (- 1.0 z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.5e+29) {
tmp = x;
} else if ((y <= 2.8e+183) || !(y <= 1.35e+207)) {
tmp = x + (z * t);
} 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 <= 8.5d+29) then
tmp = x
else if ((y <= 2.8d+183) .or. (.not. (y <= 1.35d+207))) then
tmp = x + (z * t)
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 <= 8.5e+29) {
tmp = x;
} else if ((y <= 2.8e+183) || !(y <= 1.35e+207)) {
tmp = x + (z * t);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.5e+29: tmp = x elif (y <= 2.8e+183) or not (y <= 1.35e+207): tmp = x + (z * t) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.5e+29) tmp = x; elseif ((y <= 2.8e+183) || !(y <= 1.35e+207)) tmp = Float64(x + Float64(z * t)); 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 <= 8.5e+29) tmp = x; elseif ((y <= 2.8e+183) || ~((y <= 1.35e+207))) tmp = x + (z * t); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.5e+29], x, If[Or[LessEqual[y, 2.8e+183], N[Not[LessEqual[y, 1.35e+207]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{+29}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+183} \lor \neg \left(y \leq 1.35 \cdot 10^{+207}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 8.5000000000000006e29Initial program 94.6%
Taylor expanded in x around inf 65.7%
if 8.5000000000000006e29 < y < 2.80000000000000018e183 or 1.35000000000000012e207 < y Initial program 77.6%
Taylor expanded in x around 0 35.6%
associate-*r*34.8%
associate-/r*34.8%
div-sub34.8%
rec-exp34.8%
rec-exp34.8%
tanh-def-a68.1%
Simplified68.1%
Taylor expanded in y around inf 66.2%
*-commutative66.2%
Simplified66.2%
if 2.80000000000000018e183 < y < 1.35000000000000012e207Initial program 88.1%
Taylor expanded in x around 0 87.5%
+-commutative87.5%
Simplified100.0%
Taylor expanded in x around inf 75.8%
mul-1-neg75.8%
unsub-neg75.8%
Simplified75.8%
Final simplification66.1%
(FPCore (x y z t) :precision binary64 (if (<= y 5e+22) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5e+22) {
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 <= 5d+22) 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 <= 5e+22) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5e+22: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5e+22) 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 <= 5e+22) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5e+22], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+22}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.9999999999999996e22Initial program 94.6%
Taylor expanded in x around inf 66.0%
if 4.9999999999999996e22 < y Initial program 79.3%
Taylor expanded in y around inf 76.1%
Final simplification68.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.02e+58) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.02e+58) {
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.02d+58) 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.02e+58) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.02e+58: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.02e+58) 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.02e+58) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.02e+58], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{+58}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 1.02000000000000005e58Initial program 94.3%
Taylor expanded in x around inf 65.5%
if 1.02000000000000005e58 < y Initial program 78.0%
Taylor expanded in x around 0 52.5%
+-commutative52.5%
Simplified82.9%
Taylor expanded in x around inf 51.0%
mul-1-neg51.0%
unsub-neg51.0%
Simplified51.0%
Final simplification62.5%
(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 90.9%
Taylor expanded in x around inf 60.1%
Final simplification60.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}
herbie shell --seed 2023340
(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))))))