
(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 (tanh (/ x y))) (t_2 (tanh (/ t y))))
(if (<= (- x (* (* y z) (- t_1 t_2))) 1e+308)
(fma (* y (- t_2 t_1)) z x)
(* z (- t x)))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((x / y));
double t_2 = tanh((t / y));
double tmp;
if ((x - ((y * z) * (t_1 - t_2))) <= 1e+308) {
tmp = fma((y * (t_2 - t_1)), z, x);
} else {
tmp = z * (t - x);
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(x / y)) t_2 = tanh(Float64(t / y)) tmp = 0.0 if (Float64(x - Float64(Float64(y * z) * Float64(t_1 - t_2))) <= 1e+308) tmp = fma(Float64(y * Float64(t_2 - t_1)), z, x); else tmp = Float64(z * Float64(t - x)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(x - N[(N[(y * z), $MachinePrecision] * N[(t$95$1 - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+308], N[(N[(y * N[(t$95$2 - t$95$1), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{x}{y}\right)\\
t_2 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;x - \left(y \cdot z\right) \cdot \left(t\_1 - t\_2\right) \leq 10^{+308}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(t\_2 - t\_1\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;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))))) < 1e308Initial program 98.4%
*-commutative98.4%
associate-*l*99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
+-commutative99.9%
*-commutative99.9%
fma-define100.0%
Applied egg-rr100.0%
*-rgt-identity100.0%
Simplified100.0%
if 1e308 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 40.6%
cancel-sign-sub40.6%
distribute-lft-neg-out40.6%
distribute-rgt-neg-in40.6%
neg-sub040.6%
associate-+l-40.6%
neg-sub040.6%
+-commutative40.6%
sub-neg40.6%
Simplified40.6%
Taylor expanded in t around 0 37.6%
associate-*r*0.0%
associate-/r*0.0%
rec-exp0.0%
div-sub0.0%
rec-exp0.0%
tanh-def-a34.6%
Simplified34.6%
Taylor expanded in z around inf 37.2%
associate-/l*37.2%
rec-exp37.2%
rec-exp37.2%
tanh-def-a78.4%
Simplified78.4%
Taylor expanded in y around inf 100.0%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (tanh (/ x y)) (tanh (/ t y))))) (if (<= (- x (* (* y z) t_1)) 1e+308) (- x (* z (* y t_1))) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((x / y)) - tanh((t / y));
double tmp;
if ((x - ((y * z) * t_1)) <= 1e+308) {
tmp = x - (z * (y * t_1));
} 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) :: t_1
real(8) :: tmp
t_1 = tanh((x / y)) - tanh((t / y))
if ((x - ((y * z) * t_1)) <= 1d+308) then
tmp = x - (z * (y * t_1))
else
tmp = 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((x / y)) - Math.tanh((t / y));
double tmp;
if ((x - ((y * z) * t_1)) <= 1e+308) {
tmp = x - (z * (y * t_1));
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((x / y)) - math.tanh((t / y)) tmp = 0 if (x - ((y * z) * t_1)) <= 1e+308: tmp = x - (z * (y * t_1)) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) t_1 = Float64(tanh(Float64(x / y)) - tanh(Float64(t / y))) tmp = 0.0 if (Float64(x - Float64(Float64(y * z) * t_1)) <= 1e+308) tmp = Float64(x - Float64(z * Float64(y * t_1))); else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((x / y)) - tanh((t / y)); tmp = 0.0; if ((x - ((y * z) * t_1)) <= 1e+308) tmp = x - (z * (y * t_1)); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x - N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 1e+308], N[(x - N[(z * N[(y * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{x}{y}\right) - \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;x - \left(y \cdot z\right) \cdot t\_1 \leq 10^{+308}:\\
\;\;\;\;x - z \cdot \left(y \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;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))))) < 1e308Initial program 98.4%
*-commutative98.4%
associate-*l*99.9%
Simplified99.9%
if 1e308 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 40.6%
cancel-sign-sub40.6%
distribute-lft-neg-out40.6%
distribute-rgt-neg-in40.6%
neg-sub040.6%
associate-+l-40.6%
neg-sub040.6%
+-commutative40.6%
sub-neg40.6%
Simplified40.6%
Taylor expanded in t around 0 37.6%
associate-*r*0.0%
associate-/r*0.0%
rec-exp0.0%
div-sub0.0%
rec-exp0.0%
tanh-def-a34.6%
Simplified34.6%
Taylor expanded in z around inf 37.2%
associate-/l*37.2%
rec-exp37.2%
rec-exp37.2%
tanh-def-a78.4%
Simplified78.4%
Taylor expanded in y around inf 100.0%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (tanh (/ t y))))) (if (<= y 1.15e+41) (fma t_1 z 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 <= 1.15e+41) {
tmp = fma(t_1, z, 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 <= 1.15e+41) tmp = fma(t_1, z, 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, 1.15e+41], N[(t$95$1 * z + 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 1.15 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t\_1 - x\right)\\
\end{array}
\end{array}
if y < 1.1499999999999999e41Initial program 95.2%
*-commutative95.2%
associate-*l*97.4%
Simplified97.4%
*-un-lft-identity97.4%
*-commutative97.4%
+-commutative97.4%
*-commutative97.4%
fma-define97.4%
Applied egg-rr97.4%
*-rgt-identity97.4%
Simplified97.4%
Taylor expanded in x around 0 24.7%
associate-/r*24.7%
rec-exp24.7%
div-sub24.7%
rec-exp24.7%
tanh-def-a87.0%
Simplified87.0%
if 1.1499999999999999e41 < y Initial program 91.3%
*-commutative91.3%
associate-*l*98.9%
Simplified98.9%
Taylor expanded in x around 0 62.6%
+-commutative62.6%
mul-1-neg62.6%
unsub-neg62.6%
Simplified96.7%
Final simplification89.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 1.66e+43) (+ x (* (* y z) t_1)) (+ 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 <= 1.66e+43) {
tmp = x + ((y * z) * t_1);
} 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 <= 1.66d+43) then
tmp = x + ((y * z) * t_1)
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 <= 1.66e+43) {
tmp = x + ((y * z) * t_1);
} 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 <= 1.66e+43: tmp = x + ((y * z) * t_1) 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 <= 1.66e+43) tmp = Float64(x + Float64(Float64(y * z) * t_1)); 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 <= 1.66e+43) tmp = x + ((y * z) * t_1); 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, 1.66e+43], N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $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 1.66 \cdot 10^{+43}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t\_1 - x\right)\\
\end{array}
\end{array}
if y < 1.6600000000000001e43Initial program 95.2%
*-commutative95.2%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in x around 0 24.7%
associate-*r*24.4%
associate-/r*24.4%
div-sub24.4%
rec-exp24.4%
rec-exp24.4%
tanh-def-a86.1%
*-commutative86.1%
Simplified86.1%
if 1.6600000000000001e43 < y Initial program 91.3%
*-commutative91.3%
associate-*l*98.9%
Simplified98.9%
Taylor expanded in x around 0 62.6%
+-commutative62.6%
mul-1-neg62.6%
unsub-neg62.6%
Simplified96.7%
Final simplification88.3%
(FPCore (x y z t) :precision binary64 (if (<= y 5.1e+172) (+ x (* (* y z) (tanh (/ t y)))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.1e+172) {
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 <= 5.1d+172) 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 <= 5.1e+172) {
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 <= 5.1e+172: 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 <= 5.1e+172) tmp = Float64(x + Float64(Float64(y * 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 <= 5.1e+172) 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, 5.1e+172], N[(x + N[(N[(y * z), $MachinePrecision] * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{+172}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 5.1e172Initial program 95.3%
*-commutative95.3%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in x around 0 27.5%
associate-*r*27.3%
associate-/r*27.3%
div-sub27.3%
rec-exp27.3%
rec-exp27.3%
tanh-def-a85.8%
*-commutative85.8%
Simplified85.8%
if 5.1e172 < y Initial program 85.9%
cancel-sign-sub85.9%
distribute-lft-neg-out85.9%
distribute-rgt-neg-in85.9%
neg-sub085.9%
associate-+l-85.9%
neg-sub085.9%
+-commutative85.9%
sub-neg85.9%
Simplified85.9%
Taylor expanded in y around inf 99.9%
Final simplification87.2%
(FPCore (x y z t) :precision binary64 (if (<= y 3.2e+38) x (if (<= y 1.85e+225) (- x (* x z)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.2e+38) {
tmp = x;
} else if (y <= 1.85e+225) {
tmp = x - (x * 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 <= 3.2d+38) then
tmp = x
else if (y <= 1.85d+225) then
tmp = x - (x * 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 <= 3.2e+38) {
tmp = x;
} else if (y <= 1.85e+225) {
tmp = x - (x * z);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.2e+38: tmp = x elif y <= 1.85e+225: tmp = x - (x * z) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.2e+38) tmp = x; elseif (y <= 1.85e+225) tmp = Float64(x - Float64(x * 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 <= 3.2e+38) tmp = x; elseif (y <= 1.85e+225) tmp = x - (x * z); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.2e+38], x, If[LessEqual[y, 1.85e+225], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+225}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.19999999999999985e38Initial program 95.2%
*-commutative95.2%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in x around inf 71.0%
if 3.19999999999999985e38 < y < 1.84999999999999997e225Initial program 95.5%
cancel-sign-sub95.5%
distribute-lft-neg-out95.5%
distribute-rgt-neg-in95.5%
neg-sub095.5%
associate-+l-95.5%
neg-sub095.5%
+-commutative95.5%
sub-neg95.5%
Simplified95.5%
Taylor expanded in y around inf 80.3%
Taylor expanded in x around inf 69.3%
if 1.84999999999999997e225 < y Initial program 76.3%
cancel-sign-sub76.3%
distribute-lft-neg-out76.3%
distribute-rgt-neg-in76.3%
neg-sub076.3%
associate-+l-76.3%
neg-sub076.3%
+-commutative76.3%
sub-neg76.3%
Simplified76.3%
Taylor expanded in t around 0 76.3%
associate-*r*41.7%
associate-/r*41.7%
rec-exp41.7%
div-sub41.7%
rec-exp41.7%
tanh-def-a59.1%
Simplified59.1%
Taylor expanded in z around inf 59.8%
associate-/l*59.8%
rec-exp59.8%
rec-exp59.8%
tanh-def-a75.6%
Simplified75.6%
Taylor expanded in y around inf 75.6%
Final simplification70.9%
(FPCore (x y z t) :precision binary64 (if (<= y 32000.0) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 32000.0) {
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 <= 32000.0d0) 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 <= 32000.0) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 32000.0: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 32000.0) 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 <= 32000.0) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 32000.0], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 32000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 32000Initial program 95.1%
*-commutative95.1%
associate-*l*97.3%
Simplified97.3%
Taylor expanded in x around inf 70.9%
if 32000 < y Initial program 91.9%
cancel-sign-sub91.9%
distribute-lft-neg-out91.9%
distribute-rgt-neg-in91.9%
neg-sub091.9%
associate-+l-91.9%
neg-sub091.9%
+-commutative91.9%
sub-neg91.9%
Simplified91.9%
Taylor expanded in y around inf 87.3%
Final simplification74.7%
(FPCore (x y z t) :precision binary64 (if (<= y 4.6e+169) x (* z (- t x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.6e+169) {
tmp = x;
} 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 <= 4.6d+169) then
tmp = x
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 <= 4.6e+169) {
tmp = x;
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.6e+169: tmp = x else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.6e+169) tmp = x; else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.6e+169) tmp = x; else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.6e+169], x, N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.6 \cdot 10^{+169}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.5999999999999999e169Initial program 95.3%
*-commutative95.3%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in x around inf 68.9%
if 4.5999999999999999e169 < y Initial program 85.9%
cancel-sign-sub85.9%
distribute-lft-neg-out85.9%
distribute-rgt-neg-in85.9%
neg-sub085.9%
associate-+l-85.9%
neg-sub085.9%
+-commutative85.9%
sub-neg85.9%
Simplified85.9%
Taylor expanded in t around 0 60.1%
associate-*r*44.5%
associate-/r*44.5%
rec-exp44.5%
div-sub44.5%
rec-exp44.5%
tanh-def-a78.3%
Simplified78.3%
Taylor expanded in z around inf 38.7%
associate-/l*38.7%
rec-exp38.7%
rec-exp38.7%
tanh-def-a69.5%
Simplified69.5%
Taylor expanded in y around inf 71.7%
Final simplification69.2%
(FPCore (x y z t) :precision binary64 (if (<= z 5.8e+254) x (* x (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 5.8e+254) {
tmp = x;
} else {
tmp = x * -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 (z <= 5.8d+254) then
tmp = x
else
tmp = x * -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 5.8e+254) {
tmp = x;
} else {
tmp = x * -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 5.8e+254: tmp = x else: tmp = x * -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 5.8e+254) tmp = x; else tmp = Float64(x * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 5.8e+254) tmp = x; else tmp = x * -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 5.8e+254], x, N[(x * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.8 \cdot 10^{+254}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 5.7999999999999999e254Initial program 94.8%
*-commutative94.8%
associate-*l*98.1%
Simplified98.1%
Taylor expanded in x around inf 68.3%
if 5.7999999999999999e254 < z Initial program 86.1%
cancel-sign-sub86.1%
distribute-lft-neg-out86.1%
distribute-rgt-neg-in86.1%
neg-sub086.1%
associate-+l-86.1%
neg-sub086.1%
+-commutative86.1%
sub-neg86.1%
Simplified86.1%
Taylor expanded in t around 0 23.1%
associate-*r*1.1%
associate-/r*1.1%
rec-exp1.1%
div-sub1.1%
rec-exp1.1%
tanh-def-a31.0%
Simplified31.0%
Taylor expanded in z around inf 23.5%
associate-/l*23.5%
rec-exp23.5%
rec-exp23.5%
tanh-def-a57.2%
Simplified57.2%
Taylor expanded in y around inf 66.3%
Taylor expanded in t around 0 44.4%
mul-1-neg44.4%
distribute-lft-neg-out44.4%
*-commutative44.4%
Simplified44.4%
Final simplification67.0%
(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.3%
*-commutative94.3%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in x around inf 65.0%
Final simplification65.0%
(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 2024048
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))