
(FPCore (x y z t) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))
double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0));
}
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 * 0.5d0) - y) * sqrt((z * 2.0d0))) * exp(((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.exp(((t * t) / 2.0));
}
def code(x, y, z, t): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.exp(((t * t) / 2.0))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * exp(Float64(Float64(t * t) / 2.0))) end
function tmp = code(x, y, z, t) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))
double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0));
}
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 * 0.5d0) - y) * sqrt((z * 2.0d0))) * exp(((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.exp(((t * t) / 2.0));
}
def code(x, y, z, t): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.exp(((t * t) / 2.0))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * exp(Float64(Float64(t * t) / 2.0))) end
function tmp = code(x, y, z, t) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\end{array}
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (* (sqrt (* 2.0 (* z (pow (exp (* 2.0 t)) (* t 0.5))))) (- (* 0.5 x) y)))
t = abs(t);
double code(double x, double y, double z, double t) {
return sqrt((2.0 * (z * pow(exp((2.0 * t)), (t * 0.5))))) * ((0.5 * x) - y);
}
NOTE: t should be positive before calling this function
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 = sqrt((2.0d0 * (z * (exp((2.0d0 * t)) ** (t * 0.5d0))))) * ((0.5d0 * x) - y)
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
return Math.sqrt((2.0 * (z * Math.pow(Math.exp((2.0 * t)), (t * 0.5))))) * ((0.5 * x) - y);
}
t = abs(t) def code(x, y, z, t): return math.sqrt((2.0 * (z * math.pow(math.exp((2.0 * t)), (t * 0.5))))) * ((0.5 * x) - y)
t = abs(t) function code(x, y, z, t) return Float64(sqrt(Float64(2.0 * Float64(z * (exp(Float64(2.0 * t)) ^ Float64(t * 0.5))))) * Float64(Float64(0.5 * x) - y)) end
t = abs(t) function tmp = code(x, y, z, t) tmp = sqrt((2.0 * (z * (exp((2.0 * t)) ^ (t * 0.5))))) * ((0.5 * x) - y); end
NOTE: t should be positive before calling this function code[x_, y_, z_, t_] := N[(N[Sqrt[N[(2.0 * N[(z * N[Power[N[Exp[N[(2.0 * t), $MachinePrecision]], $MachinePrecision], N[(t * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\sqrt{2 \cdot \left(z \cdot {\left(e^{2 \cdot t}\right)}^{\left(t \cdot 0.5\right)}\right)} \cdot \left(0.5 \cdot x - y\right)
\end{array}
Initial program 99.4%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in80.7%
sqrt-unprod80.7%
associate-*l*80.7%
exp-prod80.6%
pow280.6%
Applied egg-rr80.6%
distribute-lft-out99.7%
sub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
unpow299.7%
exp-prod99.8%
pow199.8%
metadata-eval99.8%
pow-sqr99.8%
pow-unpow99.8%
pow-unpow99.8%
pow-prod-down99.8%
pow299.8%
Applied egg-rr99.8%
pow-exp99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (* (- (* 0.5 x) y) (sqrt (* 2.0 (* z (exp (pow t 2.0)))))))
t = abs(t);
double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * sqrt((2.0 * (z * exp(pow(t, 2.0)))));
}
NOTE: t should be positive before calling this function
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 = ((0.5d0 * x) - y) * sqrt((2.0d0 * (z * exp((t ** 2.0d0)))))
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * Math.sqrt((2.0 * (z * Math.exp(Math.pow(t, 2.0)))));
}
t = abs(t) def code(x, y, z, t): return ((0.5 * x) - y) * math.sqrt((2.0 * (z * math.exp(math.pow(t, 2.0)))))
t = abs(t) function code(x, y, z, t) return Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(2.0 * Float64(z * exp((t ^ 2.0)))))) end
t = abs(t) function tmp = code(x, y, z, t) tmp = ((0.5 * x) - y) * sqrt((2.0 * (z * exp((t ^ 2.0))))); end
NOTE: t should be positive before calling this function code[x_, y_, z_, t_] := N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(z * N[Exp[N[Power[t, 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\left(0.5 \cdot x - y\right) \cdot \sqrt{2 \cdot \left(z \cdot e^{{t}^{2}}\right)}
\end{array}
Initial program 99.4%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in80.7%
sqrt-unprod80.7%
associate-*l*80.7%
exp-prod80.6%
pow280.6%
Applied egg-rr80.6%
distribute-lft-out99.7%
sub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Final simplification99.7%
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (* (- (* 0.5 x) y) (sqrt (* 2.0 (* z (pow (exp t) t))))))
t = abs(t);
double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * sqrt((2.0 * (z * pow(exp(t), t))));
}
NOTE: t should be positive before calling this function
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 = ((0.5d0 * x) - y) * sqrt((2.0d0 * (z * (exp(t) ** t))))
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * Math.sqrt((2.0 * (z * Math.pow(Math.exp(t), t))));
}
t = abs(t) def code(x, y, z, t): return ((0.5 * x) - y) * math.sqrt((2.0 * (z * math.pow(math.exp(t), t))))
t = abs(t) function code(x, y, z, t) return Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(2.0 * Float64(z * (exp(t) ^ t))))) end
t = abs(t) function tmp = code(x, y, z, t) tmp = ((0.5 * x) - y) * sqrt((2.0 * (z * (exp(t) ^ t)))); end
NOTE: t should be positive before calling this function code[x_, y_, z_, t_] := N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(z * N[Power[N[Exp[t], $MachinePrecision], t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\left(0.5 \cdot x - y\right) \cdot \sqrt{2 \cdot \left(z \cdot {\left(e^{t}\right)}^{t}\right)}
\end{array}
Initial program 99.4%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in80.7%
sqrt-unprod80.7%
associate-*l*80.7%
exp-prod80.6%
pow280.6%
Applied egg-rr80.6%
distribute-lft-out99.7%
sub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
unpow299.7%
exp-prod99.8%
Applied egg-rr99.8%
Final simplification99.8%
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (* (exp (/ (* t t) 2.0)) (* (- (* 0.5 x) y) (sqrt (* 2.0 z)))))
t = abs(t);
double code(double x, double y, double z, double t) {
return exp(((t * t) / 2.0)) * (((0.5 * x) - y) * sqrt((2.0 * z)));
}
NOTE: t should be positive before calling this function
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 = exp(((t * t) / 2.0d0)) * (((0.5d0 * x) - y) * sqrt((2.0d0 * z)))
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
return Math.exp(((t * t) / 2.0)) * (((0.5 * x) - y) * Math.sqrt((2.0 * z)));
}
t = abs(t) def code(x, y, z, t): return math.exp(((t * t) / 2.0)) * (((0.5 * x) - y) * math.sqrt((2.0 * z)))
t = abs(t) function code(x, y, z, t) return Float64(exp(Float64(Float64(t * t) / 2.0)) * Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(2.0 * z)))) end
t = abs(t) function tmp = code(x, y, z, t) tmp = exp(((t * t) / 2.0)) * (((0.5 * x) - y) * sqrt((2.0 * z))); end
NOTE: t should be positive before calling this function code[x_, y_, z_, t_] := N[(N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
e^{\frac{t \cdot t}{2}} \cdot \left(\left(0.5 \cdot x - y\right) \cdot \sqrt{2 \cdot z}\right)
\end{array}
Initial program 99.4%
Final simplification99.4%
NOTE: t should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* 0.5 x) y)))
(if (<= t 55.0)
(* t_1 (sqrt (* 2.0 z)))
(if (or (<= t 3.4e+46) (not (<= t 2e+119)))
(sqrt (* (* 2.0 z) (* t_1 t_1)))
(- (sqrt (* (* 2.0 z) (pow y 2.0))))))))t = abs(t);
double code(double x, double y, double z, double t) {
double t_1 = (0.5 * x) - y;
double tmp;
if (t <= 55.0) {
tmp = t_1 * sqrt((2.0 * z));
} else if ((t <= 3.4e+46) || !(t <= 2e+119)) {
tmp = sqrt(((2.0 * z) * (t_1 * t_1)));
} else {
tmp = -sqrt(((2.0 * z) * pow(y, 2.0)));
}
return tmp;
}
NOTE: t should be positive before calling this function
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 = (0.5d0 * x) - y
if (t <= 55.0d0) then
tmp = t_1 * sqrt((2.0d0 * z))
else if ((t <= 3.4d+46) .or. (.not. (t <= 2d+119))) then
tmp = sqrt(((2.0d0 * z) * (t_1 * t_1)))
else
tmp = -sqrt(((2.0d0 * z) * (y ** 2.0d0)))
end if
code = tmp
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
double t_1 = (0.5 * x) - y;
double tmp;
if (t <= 55.0) {
tmp = t_1 * Math.sqrt((2.0 * z));
} else if ((t <= 3.4e+46) || !(t <= 2e+119)) {
tmp = Math.sqrt(((2.0 * z) * (t_1 * t_1)));
} else {
tmp = -Math.sqrt(((2.0 * z) * Math.pow(y, 2.0)));
}
return tmp;
}
t = abs(t) def code(x, y, z, t): t_1 = (0.5 * x) - y tmp = 0 if t <= 55.0: tmp = t_1 * math.sqrt((2.0 * z)) elif (t <= 3.4e+46) or not (t <= 2e+119): tmp = math.sqrt(((2.0 * z) * (t_1 * t_1))) else: tmp = -math.sqrt(((2.0 * z) * math.pow(y, 2.0))) return tmp
t = abs(t) function code(x, y, z, t) t_1 = Float64(Float64(0.5 * x) - y) tmp = 0.0 if (t <= 55.0) tmp = Float64(t_1 * sqrt(Float64(2.0 * z))); elseif ((t <= 3.4e+46) || !(t <= 2e+119)) tmp = sqrt(Float64(Float64(2.0 * z) * Float64(t_1 * t_1))); else tmp = Float64(-sqrt(Float64(Float64(2.0 * z) * (y ^ 2.0)))); end return tmp end
t = abs(t) function tmp_2 = code(x, y, z, t) t_1 = (0.5 * x) - y; tmp = 0.0; if (t <= 55.0) tmp = t_1 * sqrt((2.0 * z)); elseif ((t <= 3.4e+46) || ~((t <= 2e+119))) tmp = sqrt(((2.0 * z) * (t_1 * t_1))); else tmp = -sqrt(((2.0 * z) * (y ^ 2.0))); end tmp_2 = tmp; end
NOTE: t should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t, 55.0], N[(t$95$1 * N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t, 3.4e+46], N[Not[LessEqual[t, 2e+119]], $MachinePrecision]], N[Sqrt[N[(N[(2.0 * z), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], (-N[Sqrt[N[(N[(2.0 * z), $MachinePrecision] * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]]
\begin{array}{l}
t = |t|\\
\\
\begin{array}{l}
t_1 := 0.5 \cdot x - y\\
\mathbf{if}\;t \leq 55:\\
\;\;\;\;t_1 \cdot \sqrt{2 \cdot z}\\
\mathbf{elif}\;t \leq 3.4 \cdot 10^{+46} \lor \neg \left(t \leq 2 \cdot 10^{+119}\right):\\
\;\;\;\;\sqrt{\left(2 \cdot z\right) \cdot \left(t_1 \cdot t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left(2 \cdot z\right) \cdot {y}^{2}}\\
\end{array}
\end{array}
if t < 55Initial program 99.2%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in87.3%
sqrt-unprod87.3%
associate-*l*87.3%
exp-prod87.2%
pow287.2%
Applied egg-rr87.2%
distribute-lft-out99.7%
sub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in t around 0 68.4%
if 55 < t < 3.3999999999999998e46 or 1.99999999999999989e119 < t Initial program 100.0%
Taylor expanded in t around 0 22.5%
add-sqr-sqrt13.3%
sqrt-unprod35.3%
*-commutative35.3%
*-commutative35.3%
swap-sqr37.8%
add-sqr-sqrt37.8%
pow237.8%
Applied egg-rr37.8%
*-commutative37.8%
unpow237.8%
Applied egg-rr37.8%
if 3.3999999999999998e46 < t < 1.99999999999999989e119Initial program 100.0%
Taylor expanded in t around 0 4.8%
Taylor expanded in x around 0 4.4%
mul-1-neg4.4%
associate-*l*4.4%
Simplified4.4%
add-sqr-sqrt3.5%
sqrt-unprod29.3%
*-commutative29.3%
*-commutative29.3%
swap-sqr39.9%
sqrt-prod39.9%
sqrt-prod39.9%
add-sqr-sqrt39.9%
pow239.9%
Applied egg-rr39.9%
*-commutative39.9%
*-commutative39.9%
Simplified39.9%
Final simplification61.9%
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (* (- (* 0.5 x) y) (sqrt (* 2.0 (* z (fma t t 1.0))))))
t = abs(t);
double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * sqrt((2.0 * (z * fma(t, t, 1.0))));
}
t = abs(t) function code(x, y, z, t) return Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(2.0 * Float64(z * fma(t, t, 1.0))))) end
NOTE: t should be positive before calling this function code[x_, y_, z_, t_] := N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(z * N[(t * t + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\left(0.5 \cdot x - y\right) \cdot \sqrt{2 \cdot \left(z \cdot \mathsf{fma}\left(t, t, 1\right)\right)}
\end{array}
Initial program 99.4%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in80.7%
sqrt-unprod80.7%
associate-*l*80.7%
exp-prod80.6%
pow280.6%
Applied egg-rr80.6%
distribute-lft-out99.7%
sub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in t around 0 79.9%
+-commutative79.9%
unpow279.9%
fma-def79.9%
Simplified79.9%
Final simplification79.9%
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (let* ((t_1 (- (* 0.5 x) y))) (if (<= t 50.0) (* t_1 (sqrt (* 2.0 z))) (sqrt (* (* 2.0 z) (* t_1 t_1))))))
t = abs(t);
double code(double x, double y, double z, double t) {
double t_1 = (0.5 * x) - y;
double tmp;
if (t <= 50.0) {
tmp = t_1 * sqrt((2.0 * z));
} else {
tmp = sqrt(((2.0 * z) * (t_1 * t_1)));
}
return tmp;
}
NOTE: t should be positive before calling this function
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 = (0.5d0 * x) - y
if (t <= 50.0d0) then
tmp = t_1 * sqrt((2.0d0 * z))
else
tmp = sqrt(((2.0d0 * z) * (t_1 * t_1)))
end if
code = tmp
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
double t_1 = (0.5 * x) - y;
double tmp;
if (t <= 50.0) {
tmp = t_1 * Math.sqrt((2.0 * z));
} else {
tmp = Math.sqrt(((2.0 * z) * (t_1 * t_1)));
}
return tmp;
}
t = abs(t) def code(x, y, z, t): t_1 = (0.5 * x) - y tmp = 0 if t <= 50.0: tmp = t_1 * math.sqrt((2.0 * z)) else: tmp = math.sqrt(((2.0 * z) * (t_1 * t_1))) return tmp
t = abs(t) function code(x, y, z, t) t_1 = Float64(Float64(0.5 * x) - y) tmp = 0.0 if (t <= 50.0) tmp = Float64(t_1 * sqrt(Float64(2.0 * z))); else tmp = sqrt(Float64(Float64(2.0 * z) * Float64(t_1 * t_1))); end return tmp end
t = abs(t) function tmp_2 = code(x, y, z, t) t_1 = (0.5 * x) - y; tmp = 0.0; if (t <= 50.0) tmp = t_1 * sqrt((2.0 * z)); else tmp = sqrt(((2.0 * z) * (t_1 * t_1))); end tmp_2 = tmp; end
NOTE: t should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t, 50.0], N[(t$95$1 * N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(2.0 * z), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t = |t|\\
\\
\begin{array}{l}
t_1 := 0.5 \cdot x - y\\
\mathbf{if}\;t \leq 50:\\
\;\;\;\;t_1 \cdot \sqrt{2 \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(2 \cdot z\right) \cdot \left(t_1 \cdot t_1\right)}\\
\end{array}
\end{array}
if t < 50Initial program 99.2%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in87.3%
sqrt-unprod87.3%
associate-*l*87.3%
exp-prod87.2%
pow287.2%
Applied egg-rr87.2%
distribute-lft-out99.7%
sub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in t around 0 68.4%
if 50 < t Initial program 100.0%
Taylor expanded in t around 0 16.8%
add-sqr-sqrt9.4%
sqrt-unprod26.1%
*-commutative26.1%
*-commutative26.1%
swap-sqr29.5%
add-sqr-sqrt29.5%
pow229.5%
Applied egg-rr29.5%
*-commutative29.5%
unpow229.5%
Applied egg-rr29.5%
Final simplification59.9%
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= t 29.0) (* (- (* 0.5 x) y) (sqrt (* 2.0 z))) (sqrt (* (* 2.0 z) (* y (- y x))))))
t = abs(t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 29.0) {
tmp = ((0.5 * x) - y) * sqrt((2.0 * z));
} else {
tmp = sqrt(((2.0 * z) * (y * (y - x))));
}
return tmp;
}
NOTE: t should be positive before calling this function
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 <= 29.0d0) then
tmp = ((0.5d0 * x) - y) * sqrt((2.0d0 * z))
else
tmp = sqrt(((2.0d0 * z) * (y * (y - x))))
end if
code = tmp
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 29.0) {
tmp = ((0.5 * x) - y) * Math.sqrt((2.0 * z));
} else {
tmp = Math.sqrt(((2.0 * z) * (y * (y - x))));
}
return tmp;
}
t = abs(t) def code(x, y, z, t): tmp = 0 if t <= 29.0: tmp = ((0.5 * x) - y) * math.sqrt((2.0 * z)) else: tmp = math.sqrt(((2.0 * z) * (y * (y - x)))) return tmp
t = abs(t) function code(x, y, z, t) tmp = 0.0 if (t <= 29.0) tmp = Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(2.0 * z))); else tmp = sqrt(Float64(Float64(2.0 * z) * Float64(y * Float64(y - x)))); end return tmp end
t = abs(t) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 29.0) tmp = ((0.5 * x) - y) * sqrt((2.0 * z)); else tmp = sqrt(((2.0 * z) * (y * (y - x)))); end tmp_2 = tmp; end
NOTE: t should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[t, 29.0], N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(2.0 * z), $MachinePrecision] * N[(y * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t = |t|\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 29:\\
\;\;\;\;\left(0.5 \cdot x - y\right) \cdot \sqrt{2 \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(2 \cdot z\right) \cdot \left(y \cdot \left(y - x\right)\right)}\\
\end{array}
\end{array}
if t < 29Initial program 99.2%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in87.3%
sqrt-unprod87.3%
associate-*l*87.3%
exp-prod87.2%
pow287.2%
Applied egg-rr87.2%
distribute-lft-out99.7%
sub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in t around 0 68.4%
if 29 < t Initial program 100.0%
Taylor expanded in t around 0 16.8%
add-sqr-sqrt9.4%
sqrt-unprod26.1%
*-commutative26.1%
*-commutative26.1%
swap-sqr29.5%
add-sqr-sqrt29.5%
pow229.5%
Applied egg-rr29.5%
Taylor expanded in x around 0 15.3%
+-commutative15.3%
unpow215.3%
associate-*r*15.3%
distribute-rgt-out18.8%
mul-1-neg18.8%
Simplified18.8%
Final simplification57.6%
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (* (- (* 0.5 x) y) (sqrt (* 2.0 z))))
t = abs(t);
double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * sqrt((2.0 * z));
}
NOTE: t should be positive before calling this function
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 = ((0.5d0 * x) - y) * sqrt((2.0d0 * z))
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * Math.sqrt((2.0 * z));
}
t = abs(t) def code(x, y, z, t): return ((0.5 * x) - y) * math.sqrt((2.0 * z))
t = abs(t) function code(x, y, z, t) return Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(2.0 * z))) end
t = abs(t) function tmp = code(x, y, z, t) tmp = ((0.5 * x) - y) * sqrt((2.0 * z)); end
NOTE: t should be positive before calling this function code[x_, y_, z_, t_] := N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\left(0.5 \cdot x - y\right) \cdot \sqrt{2 \cdot z}
\end{array}
Initial program 99.4%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in80.7%
sqrt-unprod80.7%
associate-*l*80.7%
exp-prod80.6%
pow280.6%
Applied egg-rr80.6%
distribute-lft-out99.7%
sub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in t around 0 57.1%
Final simplification57.1%
NOTE: t should be positive before calling this function (FPCore (x y z t) :precision binary64 (* (sqrt (* 2.0 z)) (- y)))
t = abs(t);
double code(double x, double y, double z, double t) {
return sqrt((2.0 * z)) * -y;
}
NOTE: t should be positive before calling this function
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 = sqrt((2.0d0 * z)) * -y
end function
t = Math.abs(t);
public static double code(double x, double y, double z, double t) {
return Math.sqrt((2.0 * z)) * -y;
}
t = abs(t) def code(x, y, z, t): return math.sqrt((2.0 * z)) * -y
t = abs(t) function code(x, y, z, t) return Float64(sqrt(Float64(2.0 * z)) * Float64(-y)) end
t = abs(t) function tmp = code(x, y, z, t) tmp = sqrt((2.0 * z)) * -y; end
NOTE: t should be positive before calling this function code[x_, y_, z_, t_] := N[(N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision] * (-y)), $MachinePrecision]
\begin{array}{l}
t = |t|\\
\\
\sqrt{2 \cdot z} \cdot \left(-y\right)
\end{array}
Initial program 99.4%
Taylor expanded in t around 0 57.1%
Taylor expanded in x around 0 30.7%
mul-1-neg30.7%
associate-*l*30.8%
Simplified30.8%
expm1-log1p-u30.2%
expm1-udef17.7%
sqrt-prod17.7%
Applied egg-rr17.7%
expm1-def30.2%
expm1-log1p30.9%
*-commutative30.9%
Simplified30.9%
Final simplification30.9%
(FPCore (x y z t) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (pow (exp 1.0) (/ (* t t) 2.0))))
double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * sqrt((z * 2.0))) * pow(exp(1.0), ((t * t) / 2.0));
}
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 * 0.5d0) - y) * sqrt((z * 2.0d0))) * (exp(1.0d0) ** ((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.pow(Math.exp(1.0), ((t * t) / 2.0));
}
def code(x, y, z, t): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.pow(math.exp(1.0), ((t * t) / 2.0))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * (exp(1.0) ^ Float64(Float64(t * t) / 2.0))) end
function tmp = code(x, y, z, t) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * (exp(1.0) ^ ((t * t) / 2.0)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[Exp[1.0], $MachinePrecision], N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot {\left(e^{1}\right)}^{\left(\frac{t \cdot t}{2}\right)}
\end{array}
herbie shell --seed 2023301
(FPCore (x y z t)
:name "Data.Number.Erf:$cinvnormcdf from erf-2.0.0.0, A"
:precision binary64
:herbie-target
(* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (pow (exp 1.0) (/ (* t t) 2.0)))
(* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))