Quantcast
Channel: Active questions tagged mathtools - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 122

Evaluate fractions in Binomial coefficient command

$
0
0

I'm trying to create a new command to automatically compute fractions and differences while displaying a Binomial coefficient

\usepackage{mathtools}    \DeclarePairedDelimiter\braces{(}{)}\NewDocumentCommand{\pbinom}{ m m m m }{ \binom{#2}{#1} {\braces*{#3}}^{#1} {\braces*{#4}}^{#2-#1} }

similar to the R function pbinom(q, size, prob)

In the main document I would like to simply write 1 - \pbinom{2}{18}{1/6} and the result that I would like to achieve is

\[    1 - \binom{18}{2} {\braces*{\frac{1}{6}}}^{2} {\braces*{\frac{5}{6}}}^{16}\]

Is it possible to compute differences of fractions and natural numbers in LaTeX perhaps with the use of LaTeX3?


This is a working MWE:

\documentclass[preview]{standalone}\usepackage{mathtools}\DeclarePairedDelimiter\braces{(}{)}\NewDocumentCommand{\pbinom}{ m m m m }{ \binom{#2}{#1} {\braces*{#3}}^{#1} {\braces*{#4}}^{#2-#1} }% pbinom(q, size, prob)% \NewDocumentCommand{\pbinom}{ m m m }{ \binom{#2}{#1} { ? }^{#1} { ? }^{ ? } }\begin{document}\[    1 - \pbinom{2}{18}{\frac{1}{6}}{\frac{5}{6}}\]% \[%     1 - \pbinom{2}{18}{1/6}% \]\end{document}

Viewing all articles
Browse latest Browse all 122

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>