
(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 (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 94.7%
+-commutative94.7%
associate-*l*97.6%
fma-define97.6%
Simplified97.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z))))) (if (<= t_1 5e+304) t_1 (* z (- t x)))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z));
double tmp;
if (t_1 <= 5e+304) {
tmp = 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 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z))
if (t_1 <= 5d+304) then
tmp = 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 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
double tmp;
if (t_1 <= 5e+304) {
tmp = t_1;
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) tmp = 0 if t_1 <= 5e+304: tmp = t_1 else: tmp = z * (t - x) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(y * z))) tmp = 0.0 if (t_1 <= 5e+304) tmp = t_1; else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); tmp = 0.0; if (t_1 <= 5e+304) tmp = t_1; else tmp = z * (t - x); 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[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+304], t$95$1, N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\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(y \cdot z\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;t\_1\\
\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))))) < 4.9999999999999997e304Initial program 97.6%
if 4.9999999999999997e304 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 51.3%
Taylor expanded in y around inf 51.3%
Taylor expanded in z around inf 93.8%
Taylor expanded in t around inf 93.8%
Final simplification97.3%
(FPCore (x y z t)
:precision binary64
(if (<= t -1.1e-14)
(+ x (* y (* z (tanh (/ t y)))))
(if (<= t 1e-107)
(+ x (* (* y z) (- (/ t y) (tanh (/ x y)))))
(+ x (* y (* z (tanh (* t (/ 1.0 y)))))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.1e-14) {
tmp = x + (y * (z * tanh((t / y))));
} else if (t <= 1e-107) {
tmp = x + ((y * z) * ((t / y) - tanh((x / y))));
} else {
tmp = x + (y * (z * tanh((t * (1.0 / y)))));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-1.1d-14)) then
tmp = x + (y * (z * tanh((t / y))))
else if (t <= 1d-107) then
tmp = x + ((y * z) * ((t / y) - tanh((x / y))))
else
tmp = x + (y * (z * tanh((t * (1.0d0 / y)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.1e-14) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else if (t <= 1e-107) {
tmp = x + ((y * z) * ((t / y) - Math.tanh((x / y))));
} else {
tmp = x + (y * (z * Math.tanh((t * (1.0 / y)))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.1e-14: tmp = x + (y * (z * math.tanh((t / y)))) elif t <= 1e-107: tmp = x + ((y * z) * ((t / y) - math.tanh((x / y)))) else: tmp = x + (y * (z * math.tanh((t * (1.0 / y))))) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.1e-14) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); elseif (t <= 1e-107) tmp = Float64(x + Float64(Float64(y * z) * Float64(Float64(t / y) - tanh(Float64(x / y))))); else tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t * Float64(1.0 / y)))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.1e-14) tmp = x + (y * (z * tanh((t / y)))); elseif (t <= 1e-107) tmp = x + ((y * z) * ((t / y) - tanh((x / y)))); else tmp = x + (y * (z * tanh((t * (1.0 / y))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.1e-14], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1e-107], N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * N[Tanh[N[(t * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.1 \cdot 10^{-14}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{elif}\;t \leq 10^{-107}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(t \cdot \frac{1}{y}\right)\right)\\
\end{array}
\end{array}
if t < -1.1e-14Initial program 97.4%
Taylor expanded in x around 0 9.8%
associate-/r*9.8%
div-sub9.8%
rec-exp9.8%
rec-exp9.8%
tanh-def-a86.6%
Simplified86.6%
if -1.1e-14 < t < 1e-107Initial program 95.1%
Taylor expanded in t around 0 90.2%
if 1e-107 < t Initial program 91.8%
Taylor expanded in x around 0 16.6%
associate-/r*16.6%
div-sub16.6%
rec-exp16.6%
rec-exp16.6%
tanh-def-a87.0%
Simplified87.0%
div-inv87.0%
Applied egg-rr87.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 2.9e-5)
(+ x (* y (* z t_1)))
(if (<= y 4.5e+170)
(+ x (* (* y z) (- t_1 (/ x y))))
(+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 2.9e-5) {
tmp = x + (y * (z * t_1));
} else if (y <= 4.5e+170) {
tmp = x + ((y * z) * (t_1 - (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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 2.9d-5) then
tmp = x + (y * (z * t_1))
else if (y <= 4.5d+170) then
tmp = x + ((y * z) * (t_1 - (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 t_1 = Math.tanh((t / y));
double tmp;
if (y <= 2.9e-5) {
tmp = x + (y * (z * t_1));
} else if (y <= 4.5e+170) {
tmp = x + ((y * z) * (t_1 - (x / y)));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 2.9e-5: tmp = x + (y * (z * t_1)) elif y <= 4.5e+170: tmp = x + ((y * z) * (t_1 - (x / y))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 2.9e-5) tmp = Float64(x + Float64(y * Float64(z * t_1))); elseif (y <= 4.5e+170) tmp = Float64(x + Float64(Float64(y * z) * Float64(t_1 - Float64(x / y)))); 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)); tmp = 0.0; if (y <= 2.9e-5) tmp = x + (y * (z * t_1)); elseif (y <= 4.5e+170) tmp = x + ((y * z) * (t_1 - (x / y))); 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]}, If[LessEqual[y, 2.9e-5], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.5e+170], N[(x + N[(N[(y * z), $MachinePrecision] * N[(t$95$1 - N[(x / y), $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)\\
\mathbf{if}\;y \leq 2.9 \cdot 10^{-5}:\\
\;\;\;\;x + y \cdot \left(z \cdot t\_1\right)\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+170}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(t\_1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.9e-5Initial program 96.6%
Taylor expanded in x around 0 25.1%
associate-/r*25.1%
div-sub25.1%
rec-exp25.1%
rec-exp25.1%
tanh-def-a83.8%
Simplified83.8%
if 2.9e-5 < y < 4.50000000000000022e170Initial program 96.3%
Taylor expanded in x around 0 83.3%
if 4.50000000000000022e170 < y Initial program 80.9%
Taylor expanded in y around inf 90.8%
(FPCore (x y z t) :precision binary64 (if (<= y 1.26e+169) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.26e+169) {
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 <= 1.26d+169) 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 <= 1.26e+169) {
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 <= 1.26e+169: 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 <= 1.26e+169) 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 <= 1.26e+169) 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, 1.26e+169], 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 1.26 \cdot 10^{+169}:\\
\;\;\;\;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 < 1.2599999999999999e169Initial program 96.5%
Taylor expanded in x around 0 25.9%
associate-/r*25.9%
div-sub25.9%
rec-exp25.9%
rec-exp25.9%
tanh-def-a81.8%
Simplified81.8%
if 1.2599999999999999e169 < y Initial program 80.9%
Taylor expanded in y around inf 90.8%
(FPCore (x y z t) :precision binary64 (if (<= y 27000.0) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 27000.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 <= 27000.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 <= 27000.0) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 27000.0: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 27000.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 <= 27000.0) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 27000.0], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 27000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 27000Initial program 96.6%
+-commutative96.6%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 62.4%
if 27000 < y Initial program 88.3%
Taylor expanded in y around inf 79.9%
(FPCore (x y z t) :precision binary64 (if (<= y 520000000.0) x (- x (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 520000000.0) {
tmp = x;
} else {
tmp = x - (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 <= 520000000.0d0) then
tmp = x
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 520000000.0) {
tmp = x;
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 520000000.0: tmp = x else: tmp = x - (z * x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 520000000.0) tmp = x; else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 520000000.0) tmp = x; else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 520000000.0], x, N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 520000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < 5.2e8Initial program 96.6%
+-commutative96.6%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 62.6%
if 5.2e8 < y Initial program 88.1%
Taylor expanded in y around inf 69.4%
Taylor expanded in t around 0 68.0%
mul-1-neg68.0%
unsub-neg68.0%
*-commutative68.0%
Simplified68.0%
(FPCore (x y z t) :precision binary64 (if (<= y 680000000.0) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 680000000.0) {
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 <= 680000000.0d0) 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 <= 680000000.0) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 680000000.0: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 680000000.0) 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 <= 680000000.0) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 680000000.0], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 680000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 6.8e8Initial program 96.6%
+-commutative96.6%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 62.6%
if 6.8e8 < y Initial program 88.1%
Taylor expanded in y around inf 69.4%
Taylor expanded in x around inf 68.0%
mul-1-neg68.0%
unsub-neg68.0%
Simplified68.0%
(FPCore (x y z t) :precision binary64 (if (<= z -8.5e+230) (* z (- x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.5e+230) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-8.5d+230)) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.5e+230) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.5e+230: tmp = z * -x else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.5e+230) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8.5e+230) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.5e+230], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{+230}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.499999999999999e230Initial program 90.2%
Taylor expanded in y around inf 56.2%
Taylor expanded in x around inf 40.0%
mul-1-neg40.0%
unsub-neg40.0%
Simplified40.0%
Taylor expanded in z around inf 40.0%
mul-1-neg40.0%
*-commutative40.0%
distribute-rgt-neg-in40.0%
Simplified40.0%
if -8.499999999999999e230 < z Initial program 95.1%
+-commutative95.1%
associate-*l*97.5%
fma-define97.5%
Simplified97.5%
Taylor expanded in y around 0 61.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 94.7%
+-commutative94.7%
associate-*l*97.6%
fma-define97.6%
Simplified97.6%
Taylor expanded in y around 0 58.3%
(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 2024191
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))