# How to draw the proof of Pythagoras (Bhaskara’s Proof) with Latex

I need to draw the proof of Pythagoras (Bhaskara’s Proof) (see pic below). I am still quite new to latex and don't know a lot about the tikz package. I started with the square but now I am stuck and don't know how to proceed. (the (not) diagonals are difficult for me)

How can I do this efficiently?

Thanks!

• Use GeoGebra and export the result in TikZ. This can be the first step to produce a MWE. Mar 9, 2021 at 22:15 Here's How I would do the basic shape, I'll leave the labels to you.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[thick]
\draw (0, 0) rectangle (8, 8);
\node[rotate=34.8, minimum size=2cm] (S) at (4, 4) {};
\draw (0, 0) -- (S.south east);
\draw (0, 8) -- (S.south west);
\draw (8, 0) -- (S.north east);
\draw (8, 8) -- (S.north west);
\end{tikzpicture}
\end{document}


Here's how it works. First draw the outer box. Then draw a node, S in the middle, the default node shape is square. Connect the corners of this node to corners of the outer square but going one corner anticlockwise so top left of the outer box goes to bottom left of the inner box etc. Then rotate the node. There are two ways to do this, trial and error, try angles until everything lines up nicely, or maths.

### Maths for those interested

Let d be the length of the side of the inner box, c is the length of the side of the outer box.

Then looking at the diagram we see d = a - b taking a as the longer of the two non-hypotenuse sides of the triangle.

Then we look at the triangles and notice that the angle in the bottom left from the horizontal to the almost diagonal is the same as the angle of the inner square, call this angle theta.

Applying trig definitions we know that b/c = sin(theta) and a/c = cos(theta). Hence (b - a)/c = sin(theta) - cos(theta) = d/c.

Since d and c are known (I arbitrarily chose 8 cm and 2 cm) we just need to find theta, this can be done with trig identities, or like I did, ask wolfram alpha. The answers it gives are not necessarily immediately correct, for example I had to subtract 180 degrees before I got the answer of 34.8 degrees.

• Thanks! That solution worked well for me :) Mar 10, 2021 at 0:20
• Mathematically this just uses (a - b)^2 + 4 * ab / 2. Aug 13, 2021 at 19:23

Your question title asks for a LaTeX solution, so let me propose an alternative using MetaPost ❤️:

\documentclass{standalone}
\usepackage[latex,shellescape]{gmp}
%#1 size, #2 angle
%(the triangle will have #2/2 as its least angle)
image(
for i = 1 upto 4:
%Triangles in a semi-circle are right-angled
draw (right -- dir v -- left -- cycle)
%So right angles are inner to the square
%Triangles at each side
rotated (90i-90) shifted (dir 90i)
scaled (u/2);
endfor
)
enddef;
\begin{document}
\end{document} Yet another tikz approach, parametrized and drawing "only one line".

\documentclass[border=2mm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[line join=round]
% Triangle information
\def\b{4} % catheti, b>c
\def\c{3}
\pgfmathsetmacro\B{atan(\c/\b)}       % acute angle
\pgfmathsetmacro\a{sqrt(\b*\b+\c*\c)} % hypotenuse
\foreach\i in {0,90,180,270}
{%
\begin{scope}[rotate=\i, shift={(-0.5*\a,-0.5*\a)}]
\draw (0:\a) -- (0,0) -- (\B:\b);
\end{scope}
}
\end{tikzpicture}
\end{document} • nice! thanks :) Mar 10, 2021 at 23:26

Yet another TikZ way with geometric transformations of pics, and also just one command \path. \documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[join=round,declare function={c=2;},
righttriangle/.pic={\draw[magenta] (180:c)--(0:c)--(70:c)--cycle;}]
\path
(0,0)   pic{righttriangle}
(0,2*c) pic[scale=-1]{righttriangle}
(0,0)   pic[shift={(c,c)},rotate=90]{righttriangle}
(0,0)   pic[shift={(-c,c)},rotate=-90]{righttriangle};
\end{tikzpicture}
\end{document}