Find the maximum value of $M$ with given constraints. 
Let $a, b \in \mathbb{R}$ such that $n^{4a-\log_5{n^2}} \leq 25^{40-b^2}$ for all positive real number $n$. Find the maximum value of $M=a^2+b^2+a-3b$.

What I have tried:
Taking the logarithm base 5 of both sides from the inequality, we get $(4a-2\log_5{n})\log_5n\leq2(40-b^2)$
Now, let $x=\log_5 n$, we get $x(4a-2x)\leq2(40-b^2)$, and this is equivalent to $x^2+2ax-b^2+40
\geq0$
The new inequality is true if and only if the discriminant $4a^2-4(40-b^2)\leq0$, this is equivalent to $a^2+b^2\leq40$, so we have $\max(a^2+b^2)=40$
This gave me hope of finding the maximum value of $M$ by finding the maximum value of $a-3b$ but I have no idea how to do it.
I'd like to call for some help. Thank you!
 A: I want to contribute my solution using geometry :D
As Cesareo told above, our problem now is to find the maximum value of $f(a,b)=a^2+b^2+a-3b$ knowing that $a^2+b^2 \leq 40$.
Geometrically, $\sqrt{a^2+b^2}$ is the distance between the point $M(a,b)$ and the origin $O(0,0)$, so the condition $a^2+b^2 \leq 40$ means that $M(a,b)$ lies inside the circle $(C)$ whose center and radius are respectively $O(0,0)$ and $\sqrt{40}$. By some calculations, we have
$$f(a,b)=\left(a+\dfrac{1}{2}\right)^2+\left(b-\dfrac{3}{2}\right)^2-\dfrac{5}{2}=MI^2-\dfrac{5}{2},$$
where $I\left(-\dfrac{1}{2},\dfrac{3}{2}\right)$. Hence, to find the maximum of $f(a,b)$ means to find the maximum of $MI$.
At this point, note that $I$ lies inside $(C)$ since $OI^2=\dfrac{5}{2}<40$. Therefore the position of $M$ maximizing $f(a,b)$ is one of two nodes of the diameter of $(C)$ which passes through $M$; that is,
$$\max f(a,b)=\max \left\{IA^2-\dfrac{5}{2},IB^2-\dfrac{5}{2}\right\},$$
where $AB$ is a diameter of $(C)$ containing $M$.
The following part is my calculations. The equation of the line $OI$ is $3x+y=0$. The coordinates of $A$ and $B$ satisfy the system
$$\begin{cases}
3x+y=0 \\
x^2+y^2=40
\end{cases} \Leftrightarrow \begin{cases}
y=-3x \\
x^2+(-3x)^2=40
\end{cases} \\ \begin{cases}
y=-3x \\
10x^2=40
\end{cases} \Leftrightarrow \begin{cases}
x=2 \\
y=-6
\end{cases} \vee \begin{cases}
x=-2 \\
y=6
\end{cases}$$
Thus $\max f(a,b)=\max \left\{IA^2-\dfrac{5}{2},IB^2-\dfrac{5}{2}\right\}=\max \left\{60,20\right\}=60.$
Hope this helps. ^^
A: 
$x^2+2ax-b^2+40
\geq0$

You dropped a sign: should be 
$x^2-2ax-b^2+40
\geq0.$
This won't matter to the rest of your analysis, which is good.  You reached the point of realizing that
you must have
$$a^2 + b^2 = 40 \implies $$
$$ -\sqrt{40} \leq a \leq \sqrt{40} ~~\text{and}~~ 
-\sqrt{40} \leq b \leq \sqrt{40}. \tag1 $$
So, in effect, your problem reduces to maximizing $(a - 3b)$, subject to the constraint in (1) above.
Note that for any fixed value of $a$ such that $~\displaystyle -\sqrt{40} < a < \sqrt{40}$, 
you can have that $~\displaystyle b = \pm \sqrt{40 - a^2}.$
Setting 
$\displaystyle f(a) = a \pm 3\left[40 - a^2\right]^{(1/2)} \implies $
$\displaystyle f'(a) = 1 \pm \left\{3 \times (1/2) \times \left[40 - a^2\right]^{(-1/2)} \times (-2a)\right\} \implies $
$$f'(a) = 1 \pm (3a) \times \left[40 - a^2\right])^{(-1/2)} ~: ~-\sqrt{40} < a < \sqrt{40}. \tag2 $$
Since the second derivative, $f''(a),$ is messy, I will examine the behavior of $f(a)$ solely by considering $f'(a)$ as well as the behavior of $f(a)$ at $~\displaystyle a = \pm \sqrt{40}.$
$\displaystyle f'(a) = 0 \implies 
1 \pm\frac{3a}{\sqrt{40 - a^2}} = 0.$
This implies that
$$1 = \frac{9a^2}{40 - a^2} \implies 40 - a^2 = 9a^2 \implies a = \pm 2 \implies b = \pm 6.$$
Then:

*

*$\displaystyle (a,b) = \left(-\sqrt{40},0\right) \implies (a - 3b) = -\sqrt{40}.$


*$\displaystyle (a,b) = \left(+\sqrt{40},0\right) \implies (a - 3b) = \sqrt{40}.$


*$\displaystyle (a,b) = \left(2,-6\right) \implies (a - 3b) = 20.$

So, the maximum value of $M$ is $(40 + 20) = 60.$
Edit
I just realized that my analysis can reasonably be considered to be out-of-bounds.  This is because I computed the derivative, $f'(a)$, and your problem specified the algebra-precalculus tag.
Unfortunately, I never really studied the behavior of the circle $a^2 + b^2 = 40$, from the perspective of maximizing $(a - 3b)$ solely through Analytical Geometry.  If this is really the problem composer's intent, perhaps someone else may provide an answer that does not depend on examining the derivative, $f'(a).$
