# MathCraft: PDF to LaTeX file: Sample-02

If the PDF file provided by you as follows:

Then the output LaTeX file is as follows:

\documentclass[4pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[version=4]{mhchem}
\usepackage{stmaryrd}
\usepackage{bbold}
\usepackage[a4paper]{geometry}
\textwidth 6.3truein  % These 4 commands define more efficient margins
\textheight 9.9truein
\oddsidemargin 0.0in
\evensidemargin 0.0in
\topmargin -0.75in
\parindent 0pt	% let's not indent paragraphs
\parskip 5pt
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage{wrapfig}
\author{}
\date{}
\begin{document}
\maketitle

\vspace{-0.7 in}
If $f:[a, b] \rightarrow \mathbb{R}$ is convex, then
$$f\left(\frac{a+b}{2}\right) \leqslant \frac{1}{b-a} \int_{a}^{b} f(x) d x \leqslant \frac{f(a)+f(b)}{2} .$$
\noindent\textbf{Proof}: First of all, let's recall that a convex function on a open interval $(a, b)$ is continuous on $(a, b)$ and admits left and right derivative $f_{+}^{\prime}(x)$ and $f_{-}^{\prime}(x)$ for any $x \in(a, b)$. For this reason, it's always possible to construct at least one supporting line for $f(x)$ at any $x_{0} \in(a, b)$ : if $f\left(x_{0}\right)$ is differentiable in $x_{0}$, one has $r(x)=f\left(x_{0}\right)+f^{\prime}\left(x_{0}\right)\left(x-x_{0}\right)$; if not, it's obvious that all $r(x)=f\left(x_{0}\right)+c\left(x-x_{0}\right)$ are supporting lines for any $c \in\left[f_{-}^{\prime}\left(x_{0}\right), f_{+}^{\prime}\left(x_{0}\right)\right]$.

\begin{wrapfigure}{r}{0.45\textwidth}
\includegraphics[width=0.99\linewidth]{fig01}
%\caption{Caption 1}
\label{fig:wrapfig}
\end{wrapfigure}

\vspace{.2 in}
Let now $r(x)=f\left(\frac{a+b}{2}\right)+c\left(x-\frac{a+b}{2}\right)$ be a supporting line of $f(x)$ in $x=\frac{a+b}{2} \in(a, b)$. Then, $r(x) \leq f(x)$. On the other side, by convexity definition, having defined $s(x)=f(a)+\frac{f(b)-f(a)}{b-a}(x-a)$ the line connecting the points $(a, f(a))$ and $(b, f(b))$, one has $f(x) \leq s(x)$. Shortly,
$$r(x) \leq f(x) \leq s(x)$$
Integrating both inequalities between $a$ and $b$

\begin{equation*}
\int_{a}^{b} r(x) d x \leq \int_{a}^{b} f(x) d x \leq \int_{a}^{b} s(x) d x . \tag{1}
\end{equation*}

Now
\begin{aligned} \int_{a}^{b} r(x) d x & =\int_{a}^{b}\left[f\left(\frac{a+b}{2}\right)+c\left(x-\frac{a+b}{2}\right)\right] d x \\ & =f\left(\frac{a+b}{2}\right)(b-a)+c \int_{a}^{b}\left(x-\frac{a+b}{2}\right) d x \\ & =f\left(\frac{a+b}{2}\right)(b-a), \end{aligned}
and
\begin{aligned} \int_{a}^{b} s(x) d x & =\int_{a}^{b}\left[f(a)+\frac{f(b)-f(a)}{b-a}(x-a)\right] d x \\ & =f(a)(b-a)+\frac{f(b)-f(a)}{b-a} \int_{a}^{b}(x-a) d x \\ & =\frac{f(a)+f(b)}{2}(b-a) . \end{aligned}
Using above value in (1), we have
$$f\left(\frac{a+b}{2}\right)(b-a) \leq \int_{a}^{b} f(x) d x \leq, \frac{f(a)+f(b)}{2}(b-a)$$

which is the thesis.
\end{document}