Suppose $a,b,c \in\mathbb N$, and the value of $c$ is known and fixed, while $a$ and $b$ are unknown and are both smaller than $c$. What is the total number of unique triangles possible with $a, b$ and $c$ as its sides?
What is the number of triangles with integer sides, given the length of the longest side?
-
0@ celtschk : No, you need not count them. – 2012-08-15
6 Answers
What is the total number of unique triangles possible with $a$, $b$ and $c$ as its sides?
The formula you need is $\left\lfloor\frac{(c-1)^2}{4}\right\rfloor$
As noted here, it counts "the number of noncongruent integer-sided triangles with largest side $c$". See this article as well.
-
0Your formula is correct, as is the OEIS comment about "triangles with largest side $c$". The extra triangles, allowing $b=c$, number $c$, corresponding to $a = 1,\ldots,c$. But this is precisely the difference between your $\lfloor \frac{(c-1)^2}{4} \rfloor$ and the quantity $\lfloor \frac{(c+1)^2}{4} \rfloor$ commented on in the OEIS. – 2012-08-17
For a non-degenerate triangle, we need $ c\lt a+b\quad\text{and}\quad1\le a,b\le c $
Generating Function Approach
The generating function for the number of pairs $(a,b)$ where $a+b=k$ and $1\le a,b\le c$ is $ \left(x+x^2+\cdots+x^c\right)^2=\left(x\frac{x^c-1}{x-1}\right)^2 $ Now, $ \begin{align} \sum_{k\gt c}\left[x^k\right]\left(x\frac{x^c-1}{x-1}\right)^2 &=\sum_{k\gt c}\left[x^k\right]\left(\color{#C00}{x^2}\color{#090}{-2x^{c+2}}\color{#00F}{+x^{2c+2}}\right)\sum_{j=0}^\infty(j+1)x^j\\ &=\sum_{k\gt c}\left[\color{#C00}{(k-1)_+}\color{#090}{-2(k-c-1)_+}\color{#00F}{+(k-2c-1)_+}\right]\\ &=\sum_{k\ge0}\left[(k+c)_+-2k_++(k-c)_+\right]\\ &=\sum_{k\ge0}\left[(c-k)+(k-c)_+\right]\\ &=\frac{c(c+1)}2 \end{align} $ Since we want $a\le b$, we need to add the number of ways $a=b$, which is the number of even numbers in $[c+1,2c]$, that is $\left\lfloor\frac{c+1}2\right\rfloor$, and divide by $2$: $ \bbox[5px,border:2px solid #C0A000]{\frac12\left(\frac{c(c+1)}2+\left\lfloor\frac{c+1}2\right\rfloor\right)} $
Brute Force Counting Approach
The possible choices for $a+b=k\ge c+1$ and $1\le a,b\le c$, are $ (j,k-j) $ where $k-c\le j\le c$. There are $2c-k+1$ cases for each $k$. This gives the total number of cases to be $ \begin{align} \sum_{k=c+1}^{2c}(2c-k+1) &=\sum_{k=1}^c(c-k+1)\\ &=\sum_{k=1}^ck\\[3pt] &=\frac{c(c+1)}2 \end{align} $ Since we want $a\le b$, we need to add the number of ways $a=b$, which is the number of even numbers in $[c+1,2c]$, that is $\left\lfloor\frac{c+1}2\right\rfloor$, and divide by $2$: $ \bbox[5px,border:2px solid #C0A000]{\frac12\left(\frac{c(c+1)}2+\left\lfloor\frac{c+1}2\right\rfloor\right)} $
Alternate Forms of the Answer
Form 2:
Since $c-2\left\lfloor\frac c2\right\rfloor=\frac{1-(-1)^c}2$, we get $ \begin{align} \frac12\left(\frac{c(c+1)}2+\left\lfloor\frac{c+1}2\right\rfloor\right) &=\frac12\left(\frac{c(c+1)}2+\frac{2c+1+(-1)^{c+1}}4\right)\\ &=\bbox[5px,border:2px solid #C0A000]{\frac{2c(c+2)+1-(-1)^c}8} \end{align} $ Form 3:
Since $\frac{c(c+1)}2$ is an integer, it can pass inside the floor. Since a square is either $0$ or $1$ mod $4$, $\left\lfloor\frac{(c+1)^2}2\right\rfloor$ is even. Therefore, $ \begin{align} \frac12\left(\frac{c(c+1)}2+\left\lfloor\frac{c+1}2\right\rfloor\right) &=\frac12\left\lfloor\frac{(c+1)^2}2\right\rfloor\\ &=\bbox[5px,border:2px solid #C0A000]{\left\lfloor\frac{(c+1)^2}4\right\rfloor} \end{align} $
-
0I got the answer thanks... – 2017-11-22
Depending on whether you consider $(a,b,c)=(3,4,5)$ to give a different triangle from $(a,b,c)=(4,3,5)$, you seem to be either asking for the number of elements in $ \{\,(a,b)\in\mathbb N^2\mid 0n\,\} $ or for the number of elements in $ \{\,(a,b)\in\mathbb N^2\mid 0n\,\}. $ Surely you can find the answers to these easy questions? Make a drawing of dots inside a square if you need to.
Hint: Use the triangle inequality. If $a\leq b\leq c$, it is only required that $a+b>c$, so we need to count the number of pairs $(a,b)$ such that $a\leq b\leq c$ and $c. Can you go from here?
-
0@Akulsharma I'll add a little more to my answer. – 2017-11-19
I wrote a little program who gave me the results in the table, but I can't find a closed formula to get numbers of triangles $n$ directly from $c$
Hope this can be useful
Edit
I found it! Thanks to Mathematica, which means I don't know exactly how to explain
$n=\frac{1}{8} \left[2 c (c+2)+(-1)^{c+1}+1\right]$ $...$
$ \begin{array}{r|r} c & n\\ \hline 5 & 9 \\ 10 & 30 \\ 15 & 64 \\ 20 & 110 \\ 25 & 169 \\ 30 & 240 \\ 35 & 324 \\ 40 & 420 \\ 45 & 529 \\ 50 & 650 \\ 55 & 784 \\ 60 & 930 \\ 65 & 1089 \\ 70 & 1260 \\ 75 & 1444 \\ 80 & 1640 \\ 85 & 1849 \\ 90 & 2070 \\ 95 & 2304 \\ 100 & 2550 \\ \end{array} $