Skip to content

Instantly share code, notes, and snippets.

@simonw
Created July 9, 2022 17:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonw/5741ffa7e21dd8c2f1b845f6a0c48d5a to your computer and use it in GitHub Desktop.
Save simonw/5741ffa7e21dd8c2f1b845f6a0c48d5a to your computer and use it in GitHub Desktop.

Explaining mathematical expressions with GPT-3

I wanted to see if GPT-3 could explain a mathematical expression for me, as a follow-on from Using GPT-3 to explain how code works. I grabbed an example from this page of the GitHub documentation.

Here's my conversation with GPT-3 as plain text - except I added > to the lines that I entered to differentiate them from the GPT-3 output:

> Explain this:
>
> $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

This is the Cauchy-Schwarz inequality.

> Explain the formula syntax step by step, using $$ wrapped around the formula steps:

$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

This is the Cauchy-Schwarz inequality.

$$\left( \sum_{k=1}^n a_k b_k \right)^2$$

This is the sum of all products of corresponding elements in the vectors a and b, squared.

$$\leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

This is saying that this sum is less than or equal to the product of the sums of the squares of each vector.

The reason I said "using $$ wrapped around the formula steps" was to get the output to be produced in the syntax that GitHub Markdown understands. It worked! Here's the rendered version of my conversation:


Explain this:

$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

This is the Cauchy-Schwarz inequality.

Explain the formula syntax step by step, using $$ wrapped around the formula steps:

$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

This is the Cauchy-Schwarz inequality.

$$\left( \sum_{k=1}^n a_k b_k \right)^2$$

This is the sum of all products of corresponding elements in the vectors a and b, squared.

$$\leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

This is saying that this sum is less than or equal to the product of the sums of the squares of each vector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment