# How Does SPF Work? So I went on vacation recently, which was nice.

One of the conversations that came up, which I’m sure does for many folks on vacation, was around the application of sunscreen. How often should you re-apply? How long will SPF 50 last vs. SPF 15? And then as we were talking, an even more fundamental question arose – what the hell is SPF anyway, and how does it work?

I’d always assumed in the past, like I assume many other people do, that it was a linear scale – so SPF 60 was 4x ‘as good’ as SPF 15. Someone in our group also said that the number was supposed to be a measure of duration for sun exposure. So, for SPF 60 you could go in direct sunlight for an hour longer than you would normally without burning whereas whereas for SPF 15 it’d only be a quarter of that.

Apparently as it turns out, neither of these things are true.

#### What is SPF?

SPF stands for ‘sun protection factor’

According to Wikipedia, the SPF rating was first introduced in 1974, and it is  measure of the proportion of UV rays which a sunblock allows to reach the skin.  Apparently UV-A is what actually causes the sun damage to the skin that results in sunburn. So, technically speaking, SPF is actually more like a percentage – hence it being unitless.

As such, when it comes to the duration of sun exposure, using the SPF scale must be done relatively and is multiplicative of the time you would normally burn in – it is not a measure of an amount of time. The rule of thumb I have read on various pages is that, for example, if you’d normally burn in direct sunlight in 10 minutes, then SPF 15 allows you to spend 15x that or 150 minutes without burning.

Even this is a pretty big approximation, as it’s very difficult to estimate the amount of sun exposure over a given time period due to the large number of factors which make it variable, as many other blog posts (and Dermatological Associations) note.

It’s also important to remember that a higher SPF does not mean that it needs to be re-applied less frequently.

#### The Mathematics of Sunscreen

An interesting point to note that I’d always incorrectly taken for granted is that the SPF scale is not linear.

According to many sites, the breakdown is as below:

• SPF 4 blocks 75 percent of UVB rays
• SPF 8 blocks 87 percent of UVB rays
• SPF 15 blocks 93 percent of UVB rays
• SPF 30 blocks 97 percent of UVB rays
• SPF 50 blocks 98 percent of UVB rays
• SPF 100 blocks 99 percent of UVB rays

I’m not so good with lists of numbers, so let’s put this into a nice visual:

Wow! As you can see, even just wearing SPF 4 is blocking nearly 3 quarters of the UV of SPF 100. Very surprising, and now I take back all the times I either poked fun at someone buying sunscreen with very low SPF or wondered why they even sell it in the first place.

We can treat the percentage of UV blocked as a function of the SPF, using an exponential function of the form below: where for us, will be the percentage of UV blocked and will be the SPF.

Using numpy and following code like that demonstrated here we get the below:

```import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit

# Initialize data
SPF = np.array([4, 8, 15, 30, 50, 100])
pcts = np.array([75,87,93,97,98,99])

# Fit exponential function
def func(t, a, b, alpha):
return a + b * np.exp(-alpha * t)

# initial guess for curve fit coefficients
a0 = 0
b0 = 0
alpha0 = 0

# coefficients and curve fit
coefs = curve_fit(func, SPF, pcts, p0=(a0, b0, alpha0))

# Pull out coefficients
a = coefs
b = coefs
alpha = coefs

# Print coefficients
print(a, b, alpha)

# Interpolate and fit
x = np.linspace(1, 100, 100)
y = func(x, a, b, alpha)

# Plot
plt.figure()
plt.plot(SPF, pcts, label='actual', marker='o')
plt.plot(x, y, label='fitted', marker='.')
plt.xlabel('SPF')
plt.ylabel('% of UV-A blocked')
plt.legend()
plt.show()

```

`98.02333353234812 -42.4890366352703 0.15725468017531208` Cool! Not a perfect fit but does a decent job. Our final expression to approximate the UV blocked is: So, if they made SPF 14, our function says it would block: or ~93.3% of UV-A rays.

#### Conclusion

As the analysis has shown, even wearing a very low SPF like 8 is still much better than nothing, and there isn’t that much difference going higher once you get above SPF 30 or so.

The moral of the story? Follow the advice of the 90’s and wear suncreen, even if it’s just SPF 4!

#### References

Sunscreen (Wikipedia)
https://en.wikipedia.org/wiki/Sunscreen

What is SPF Sunscreen?