If $AB = 9$ and $AC:BC=40:41$, then find maximum area of $\triangle ABC$. (via Brilliant) This is a question from Brilliant.org

The triangle $ABC$ has $AB = 9$ and $AC:BC = 40:41$. What is the maximum possible area of $ABC$?

For this question, I considered the equation $A=\frac 12ab\sin\theta$.
Since $\sin\theta\le 1$, then $A$ is maximised when $\sin\theta = 1$.
This meant $ABC$ was a right-angled triangle, after some working I got the answer as 180.
However, it was wrong, Brilliant said it is not necessarily a right-angled triangle and then used Heron's formula to find the maximised area, 820.
I checked other posts which were similar to my question such as, How to maximize the area of a triangle, given two sides?. However, they followed the same method I did
I am interested in why a right-angled triangle would not maximise the area in this case and what is wrong with my logic?
 A: Your confusion stems from the fact that the area is maximized at $\theta=90$, if you keep the side lengths $BC,AC$ fixed. However in this problem $BC,AC$ can vary in length. 
A: Let the sides $AC=40x, BC=41x$.
Using the Heron's formula:
$$S=\sqrt{\frac{81x+9}{2}\cdot \frac{81x-9}{2}\cdot \frac{9+x}{2}\cdot \frac{9-x}{2}}=\frac{81}{4}\sqrt{\left(x^2-\frac 1{81}\right)\left(81-x^2\right)}\overbrace{\le}^{GM-AM} \\
\frac{81}{4}\cdot \frac{\left(x^2-\frac 1{81}\right)+\left(81-x^2\right)}{2}=820,$$
equality occurs when $x^2-\frac1{81}=81-x^2 \Rightarrow x\approx 3$.
Note: $GM-AM$ is the Geometric Mean-Arithmetic Mean inequality.
A: As mentioned in a comment, the best way to realize where is the error is to consider the similar problem where $AB=9$ is given and fixed, and where $AC:BC=1$. Then in this case the triangle is isosceles, and we have the option to choose its height as big as we want. The bigger this heigth $h$, (the smaller the angle in $C$, and) the bigger the area. There is no limit for the area, we can let $h$ tend to infinity, the area goes to infinity!
As seen also in this example, in the given situation the sides $a=BC$, $b=AC$ and the angle in $C$ variate together in a "complicated way", and contribute more or less to the area. A maximum for $\sin \hat C$ does not lead to a maximal area, since the sides $a,b$, and the height $h$ are dramatically constrained to be "small".

Now let us also give a simple solution to the "brilliant" problem.
First of all, let us consider the following example of a triangle satisfying the given conditions, the one with sides $9,40,41$.
Yes, it has a right angle, but not there where i supposed first that the question supposed it to be... In a (bad) picture:

(Sorry, i cannot get it smaller. But maybe it is psychologically good so.)
A possible choice of $C$ is as above, in the position which makes the angle in $B$ a right angle. An other position is the symmetrical position, which makes the angle in $A$ a right angle. With the one or the other choice we get a first weak attempt to maximize the area, it is $\frac 12\cdot 9\cdot 40=180$.
Now let us try to get a better guess. Consider a point on $AB$ which divides $AB$ in two parts, $s$ and $9-s$.
In fact we allow
$$s\in\Bbb R\ ,$$
for a negative value of $s$ we consider the point on $AB$ to be on the half-line $(AB$ "after" $B$.
We draw a long perpendicular in this point to $AB$, choose on it that one point (in the "upper" half-plane)  $C''$, so that the sides 
$AC$ and $BC$ are in the given proportion:
$$
\frac{AC''}{BC''}=\frac{41}{40}\ .
$$
This is maybe possible, maybe impossible.
(For instance, for $s=9/2$ this is impossible.) If it is possible, we want to get the height $h=h(s)$ as a function of $s$, that we will maximize.
The above figure is maybe wrong, maybe $C''$ is so that the corresponding  height is $\le 40$, and maybe it is there where $?C''$ is placed, well, we have to compute. (Yes, it is wrong.) 
Note: This is somehow related to the posted question. It turns out, that the maximal height is obtained for a negative $s$, (which is relatively big in absolute value,) the point on the line $AB$ which realizes the maximal height is not on the segment $AB$.
Computations. Note that from
$$
\frac{41}{40}
=\frac{AC''}{BC''}=
\frac
{\sin \hat B}
{\sin \hat A}
=
\frac
{h/\sqrt{h^2+s^2}}
{h/\sqrt{h^2+(9-s)^2}}
=
\frac
{\sqrt{h^2+(9-s)^2}}
{\sqrt{h^2+s^2}}
$$
we get a simple relation determining $h$,
$$
\frac{41^2}{40^2}
=
\frac
{h^2+(9-s)^2}
{h^2+s^2}
\ ,
$$
so
$$
\begin{aligned}
\underbrace{(41^2-40^2)}_{=9^2}h^2 
&= 
40^2(9-s)^2-41^2s^2
\\
&=
9(40-9s)(s+360)\ .
\end{aligned}
$$
The roots of the last expression are $40/9$ and $-360$.
To have a positive quantity, we need $40-9s\ge 0$, so $s\le 40/9$.
The maximal value of the expression is taken exactly in the middle of the segment determined by the roots, which is $s^*=-1600/9$. For this value of the $s$-variable we get a corresponding maximal $h^*$, which is
$$
h^*
=\frac 19\sqrt{9\cdot (40+1600)\left(-\frac {1600}9+360\right)}
=
\frac {1640}9\ .
$$
So the maximal area is $\frac 12 \cdot AB\cdot h^*=\frac{1640}2=820$.
A: Since we have expressions for the side lengths as
$a,b=px,c=qx$ ($a=9,p=40,q=41$),
we can ignore all the angles and
use Heron’s formula for the area
\begin{align} 
S&=\tfrac14\sqrt{4a^2b^2-(a^2+b^2-c^2)^2}
\tag{1}\label{1}
,\\
S(x)&=\tfrac14\sqrt{2x^2a^2(q^2+p^2)-x^4(p-q)^2(q+p)^2-a^4}
\tag{2}\label{2}
.
\end{align}  
The $x$ that maximizes the area $S(x)$, 
also maximizes $S(x)^2$,
so we can consider 
\begin{align}
S_2(x)&=S(x)^2=\tfrac1{16}(2x^2a^2(q^2+p^2)-x^4(p-q)^2(q+p)^2-a^4)
,\\
S_2'(x)&=
\tfrac14x(a^2(q^2+p^2)-(p-q)^2(q+p)^2x^2)
\end{align}
And the sought maximum can be found at
\begin{align}
x_{\max}&= 
\frac{a\sqrt{q^2+p^2}}{q^2-p^2}
=\tfrac19\sqrt{3281}
\approx 6.36
,\\
S_{\max}&=
S(x_{\max})=820
.
\end{align}
