# Pythagorean theorem

> A 3-4-5 right triangle with a square on each side, so a² + b² = c² can be seen as area. A Geometry example with its LaTeX source.

A Geometry example in the TeXeR TikZ library: https://texer.org/library/geometry/pythagoras

Package: [Geometry](https://texer.org/library/geometry.md), on CTAN at https://ctan.org/pkg/pgf.

Tags: Pythagorean theorem, right triangle, proof

## Source

```latex
\begin{tikzpicture}[scale=0.55, thick]
  \draw[fill=blue!15] (0,0) -- (0,3) -- (-3,3) -- (-3,0) -- cycle;
  \draw[fill=orange!20] (0,0) -- (4,0) -- (4,-4) -- (0,-4) -- cycle;
  \draw[fill=green!20] (4,0) -- (0,3) -- (3,7) -- (7,4) -- cycle;
  \draw[fill=white] (0,0) -- (4,0) -- (0,3) -- cycle;
  \draw (0,0) rectangle (0.5,0.5);
  \node at (-1.5,1.5) {$a^2$};
  \node at (2,-2) {$b^2$};
  \node at (3.5,3.5) {$c^2$};
  \node[left] at (0,1.5) {$a$};
  \node[below] at (2,0) {$b$};
  \node[above right] at (2,1.5) {$c$};
\end{tikzpicture}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[scale=0.55, thick]
  \draw[fill=blue!15] (0,0) -- (0,3) -- (-3,3) -- (-3,0) -- cycle;
  \draw[fill=orange!20] (0,0) -- (4,0) -- (4,-4) -- (0,-4) -- cycle;
  \draw[fill=green!20] (4,0) -- (0,3) -- (3,7) -- (7,4) -- cycle;
  \draw[fill=white] (0,0) -- (4,0) -- (0,3) -- cycle;
  \draw (0,0) rectangle (0.5,0.5);
  \node at (-1.5,1.5) {$a^2$};
  \node at (2,-2) {$b^2$};
  \node at (3.5,3.5) {$c^2$};
  \node[left] at (0,1.5) {$a$};
  \node[below] at (2,0) {$b$};
  \node[above right] at (2,1.5) {$c$};
\end{tikzpicture}
\end{document}
```
