
(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 (- (* (tanh (/ t y)) z) (* z (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(y, ((tanh((t / y)) * z) - (z * tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(y, Float64(Float64(tanh(Float64(t / y)) * z) - Float64(z * tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(y * N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision] - N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \tanh \left(\frac{t}{y}\right) \cdot z - z \cdot \tanh \left(\frac{x}{y}\right), x\right)
\end{array}
Initial program 94.6%
+-commutative94.6%
associate-*l*97.9%
fma-define98.0%
Simplified98.0%
sub-neg98.0%
distribute-rgt-in98.0%
Applied egg-rr98.0%
Final simplification98.0%
(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.6%
+-commutative94.6%
associate-*l*97.9%
fma-define98.0%
Simplified98.0%
(FPCore (x y z t) :precision binary64 (if (<= y 2.7e+189) (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e+189) {
tmp = x + ((tanh((t / y)) - tanh((x / 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 <= 2.7d+189) then
tmp = x + ((tanh((t / y)) - tanh((x / 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 <= 2.7e+189) {
tmp = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.7e+189: tmp = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.7e+189) tmp = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / 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 <= 2.7e+189) tmp = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.7e+189], 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], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{+189}:\\
\;\;\;\;x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.69999999999999994e189Initial program 95.0%
if 2.69999999999999994e189 < y Initial program 90.0%
Taylor expanded in y around inf 95.3%
Final simplification95.0%
(FPCore (x y z t) :precision binary64 (+ x (* y (- (* (tanh (/ t y)) z) (* z (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * ((tanh((t / y)) * z) - (z * 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 * ((tanh((t / y)) * z) - (z * tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * ((Math.tanh((t / y)) * z) - (z * Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * ((math.tanh((t / y)) * z) - (z * math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(Float64(tanh(Float64(t / y)) * z) - Float64(z * tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * ((tanh((t / y)) * z) - (z * tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision] - N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(\tanh \left(\frac{t}{y}\right) \cdot z - z \cdot \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Initial program 94.6%
+-commutative94.6%
associate-*l*97.9%
fma-define98.0%
Simplified98.0%
sub-neg98.0%
distribute-rgt-in98.0%
Applied egg-rr98.0%
Taylor expanded in y around 0 15.7%
Simplified97.9%
Final simplification97.9%
(FPCore (x y z t) :precision binary64 (if (or (<= t -2.9e-85) (not (<= t 1.2e-36))) (+ x (* y (* (tanh (/ t y)) z))) (- x (* (tanh (/ x y)) (* y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.9e-85) || !(t <= 1.2e-36)) {
tmp = x + (y * (tanh((t / y)) * z));
} else {
tmp = x - (tanh((x / y)) * (y * 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 ((t <= (-2.9d-85)) .or. (.not. (t <= 1.2d-36))) then
tmp = x + (y * (tanh((t / y)) * z))
else
tmp = x - (tanh((x / y)) * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.9e-85) || !(t <= 1.2e-36)) {
tmp = x + (y * (Math.tanh((t / y)) * z));
} else {
tmp = x - (Math.tanh((x / y)) * (y * z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -2.9e-85) or not (t <= 1.2e-36): tmp = x + (y * (math.tanh((t / y)) * z)) else: tmp = x - (math.tanh((x / y)) * (y * z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -2.9e-85) || !(t <= 1.2e-36)) tmp = Float64(x + Float64(y * Float64(tanh(Float64(t / y)) * z))); else tmp = Float64(x - Float64(tanh(Float64(x / y)) * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -2.9e-85) || ~((t <= 1.2e-36))) tmp = x + (y * (tanh((t / y)) * z)); else tmp = x - (tanh((x / y)) * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.9e-85], N[Not[LessEqual[t, 1.2e-36]], $MachinePrecision]], N[(x + N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{-85} \lor \neg \left(t \leq 1.2 \cdot 10^{-36}\right):\\
\;\;\;\;x + y \cdot \left(\tanh \left(\frac{t}{y}\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - \tanh \left(\frac{x}{y}\right) \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if t < -2.9000000000000002e-85 or 1.2e-36 < t Initial program 96.2%
Taylor expanded in x around 0 13.3%
associate-/r*13.3%
div-sub13.3%
rec-exp13.3%
rec-exp13.3%
tanh-def-a87.2%
Simplified87.2%
if -2.9000000000000002e-85 < t < 1.2e-36Initial program 92.4%
+-commutative92.4%
associate-*l*97.0%
fma-define97.0%
Simplified97.0%
sub-neg97.0%
distribute-rgt-in97.0%
Applied egg-rr97.0%
Taylor expanded in t around 0 24.3%
mul-1-neg24.3%
unsub-neg24.3%
associate-/l*25.2%
associate-/l*25.2%
rec-exp25.2%
div-sub25.2%
Simplified81.0%
Final simplification84.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 2.6e-63) (+ x (* y (* t_1 z))) (+ 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 <= 2.6e-63) {
tmp = x + (y * (t_1 * z));
} 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 <= 2.6d-63) then
tmp = x + (y * (t_1 * z))
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 <= 2.6e-63) {
tmp = x + (y * (t_1 * z));
} 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 <= 2.6e-63: tmp = x + (y * (t_1 * z)) 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 <= 2.6e-63) tmp = Float64(x + Float64(y * Float64(t_1 * z))); 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 <= 2.6e-63) tmp = x + (y * (t_1 * z)); 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, 2.6e-63], N[(x + N[(y * N[(t$95$1 * z), $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 2.6 \cdot 10^{-63}:\\
\;\;\;\;x + y \cdot \left(t\_1 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t\_1 - x\right)\\
\end{array}
\end{array}
if y < 2.6000000000000001e-63Initial program 94.4%
Taylor expanded in x around 0 20.1%
associate-/r*20.1%
div-sub20.1%
rec-exp20.1%
rec-exp20.1%
tanh-def-a76.1%
Simplified76.1%
if 2.6000000000000001e-63 < y Initial program 95.4%
Taylor expanded in x around 0 52.9%
+-commutative52.9%
Simplified89.6%
Final simplification79.4%
(FPCore (x y z t) :precision binary64 (if (<= y 2.25e+176) (+ x (* y (* (tanh (/ t y)) z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.25e+176) {
tmp = x + (y * (tanh((t / 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 <= 2.25d+176) then
tmp = x + (y * (tanh((t / 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 <= 2.25e+176) {
tmp = x + (y * (Math.tanh((t / y)) * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.25e+176: tmp = x + (y * (math.tanh((t / y)) * z)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.25e+176) tmp = Float64(x + Float64(y * Float64(tanh(Float64(t / 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 <= 2.25e+176) tmp = x + (y * (tanh((t / y)) * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.25e+176], N[(x + N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.25 \cdot 10^{+176}:\\
\;\;\;\;x + y \cdot \left(\tanh \left(\frac{t}{y}\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.25000000000000002e176Initial program 94.9%
Taylor expanded in x around 0 23.8%
associate-/r*23.8%
div-sub23.8%
rec-exp23.8%
rec-exp23.8%
tanh-def-a77.7%
Simplified77.7%
if 2.25000000000000002e176 < y Initial program 92.1%
Taylor expanded in y around inf 92.8%
Final simplification79.1%
(FPCore (x y z t) :precision binary64 (if (<= y 2.5e+16) x (if (<= y 2.85e+115) (- x (* z x)) (+ x (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.5e+16) {
tmp = x;
} else if (y <= 2.85e+115) {
tmp = x - (z * x);
} else {
tmp = x + (t * 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 <= 2.5d+16) then
tmp = x
else if (y <= 2.85d+115) then
tmp = x - (z * x)
else
tmp = x + (t * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.5e+16) {
tmp = x;
} else if (y <= 2.85e+115) {
tmp = x - (z * x);
} else {
tmp = x + (t * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.5e+16: tmp = x elif y <= 2.85e+115: tmp = x - (z * x) else: tmp = x + (t * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.5e+16) tmp = x; elseif (y <= 2.85e+115) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x + Float64(t * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.5e+16) tmp = x; elseif (y <= 2.85e+115) tmp = x - (z * x); else tmp = x + (t * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.5e+16], x, If[LessEqual[y, 2.85e+115], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5 \cdot 10^{+16}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.85 \cdot 10^{+115}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot z\\
\end{array}
\end{array}
if y < 2.5e16Initial program 94.8%
Taylor expanded in x around inf 65.2%
if 2.5e16 < y < 2.84999999999999983e115Initial program 99.8%
Taylor expanded in y around inf 70.4%
Taylor expanded in t around 0 67.8%
mul-1-neg67.8%
unsub-neg67.8%
*-commutative67.8%
Simplified67.8%
if 2.84999999999999983e115 < y Initial program 92.3%
Taylor expanded in t around 0 85.0%
Taylor expanded in y around 0 70.7%
+-commutative70.7%
Simplified70.7%
Final simplification66.1%
(FPCore (x y z t) :precision binary64 (if (<= y 8e-26) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8e-26) {
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 <= 8d-26) 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 <= 8e-26) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8e-26: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8e-26) 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 <= 8e-26) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8e-26], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-26}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 8.0000000000000003e-26Initial program 94.6%
Taylor expanded in x around inf 64.5%
if 8.0000000000000003e-26 < y Initial program 94.7%
Taylor expanded in y around inf 79.2%
(FPCore (x y z t) :precision binary64 (if (<= y 9e+73) x (+ x (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9e+73) {
tmp = x;
} else {
tmp = x + (t * 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 <= 9d+73) then
tmp = x
else
tmp = x + (t * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9e+73) {
tmp = x;
} else {
tmp = x + (t * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 9e+73: tmp = x else: tmp = x + (t * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 9e+73) tmp = x; else tmp = Float64(x + Float64(t * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 9e+73) tmp = x; else tmp = x + (t * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 9e+73], x, N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{+73}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot z\\
\end{array}
\end{array}
if y < 8.99999999999999969e73Initial program 94.9%
Taylor expanded in x around inf 64.9%
if 8.99999999999999969e73 < y Initial program 93.2%
Taylor expanded in t around 0 86.4%
Taylor expanded in y around 0 71.5%
+-commutative71.5%
Simplified71.5%
Final simplification66.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.6%
Taylor expanded in x around inf 61.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 2024112
(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))))))