# Fresnel equation with incident angle, n and k as input

I've seen a Fresnel equation for calculating the reflection amount at incidence angle with n and k values defined. This formula usually comes up in relation to computer graphics, but I can't find this equation anywhere in a science context.

Here is an example written in Python, taken from the website Fresnel Formula in python:

def IOR(n,k):
theta_deg = 0

n = n
k = k
fresnel = []

while theta_deg <= 90:

a = math.sqrt((math.sqrt((n**2-k**2-(math.sin(theta))**2)**2 + ((4 * n**2) * k**2)) + (n**2 - k**2 - (math.sin(theta))**2))/2)

b = math.sqrt((math.sqrt((n**2-k**2-(math.sin(theta))**2)**2 + ((4 * n**2) * k**2)) - (n**2 - k**2 - (math.sin(theta))**2))/2)

Fs = (a**2+b**2-(2 * a * math.cos(theta))+(math.cos(theta))**2)/(a**2+b**2+(2 * a * math.cos(theta))+(math.cos(theta))**2)
Fp = Fs * ((a**2+b**2-(2 * a * math.sin(theta) * math.tan(theta))+(math.sin(theta))**2*(math.tan(theta))**2)/(a**2+b**2+(2 * a * math.sin(theta) * math.tan(theta))+(math.sin(theta))**2*(math.tan(theta))**2))
R = (Fs + Fp)/2
fresnel.append(R)

theta_deg += 1
return fresnel


I can't find any references online for this formula, the Wikipedia article on Fresnel equations contains completely different formulas, and I can't see the connection between them. I've searched high and low, but can't find any reference to this particular formula, why is that? Can you help me find it, or explain to me why I can't find it online? Or could you show me how to derive it from the Fresnel formulas from the Wikipedia article?

Yes, I realize that I already have the formula right there in the code sample. But I'm baffled over why I can't find this formula anywhere, I would like to have more sources to cite then just this code example.

@PaulHK's answer is correct I'm sure, here's a bit of a check to show that the IOR() function is calculating the reflection coefficients for $s$ and $p$ polarizations then averaging the two assuming unpolarized incident light.

The reflection is for a single interface, and at least at normal incidence the results reduce to the simpler $(n_2-n_1)^2/(n_2+n_1)^2$. With this script you can check against other on-line calculators using non-zero incident angle and nonzero values for $k$.

I cleaned up the python a bit (indents) and added the plot. You can see when exiting from glass to air, the reflectivity goes to 100% at the critical angle for total internal reflection:  def IOR(n,k):
theta_deg = 0

fresnel = []

while theta_deg <= 90:

a = math.sqrt((math.sqrt((n**2-k**2-(math.sin(theta))**2)**2 +
((4 * n**2) * k**2)) + (n**2 - k**2 -
(math.sin(theta))**2))/2)

b = math.sqrt((math.sqrt((n**2-k**2-(math.sin(theta))**2)**2 +
((4 * n**2) * k**2)) - (n**2 - k**2 -
(math.sin(theta))**2))/2)

Fs = (a**2+b**2-(2 * a * math.cos(theta))+
(math.cos(theta))**2)/(a**2+b**2 +
(2 * a * math.cos(theta))+(math.cos(theta))**2)

Fp = Fs * ((a**2+b**2 -
(2 * a * math.sin(theta) * math.tan(theta)) +
(math.sin(theta))**2*(math.tan(theta))**2)/(a**2+b**2 +
(2 * a * math.sin(theta) * math.tan(theta)) +
(math.sin(theta))**2*(math.tan(theta))**2))

R = (Fs + Fp)/2

fresnel.append((R, Fs, Fp))

theta_deg += 1
return fresnel

import math
import matplotlib.pyplot as plt

n1, n2  = 1.00, 1.45  # into glass, one side only
n2ovrn1 = n2/n1

Rin, Fsin, Fpin = zip(*IOR(n2ovrn1, 0))

print Rin
print (n2ovrn1-1.0)**2 / (n2ovrn1+1.0)**2  # check

n1, n2  = 1.45, 1.00  # outof glass, one side only
n2ovrn1 = n2/n1

Rout, Fsout, Fpout = zip(*IOR(n2ovrn1, 0))

print Rout
print (n2ovrn1-1.0)**2 / (n2ovrn1+1.0)**2  # check

plt.figure()
plt.plot(range(91), Rin, '-k', linewidth=2)
plt.plot(range(91), Rout, '-k', linewidth=2)
plt.plot(range(91), Fsin, '-k')
plt.plot(range(91), Fsout, '-k')
plt.plot(range(91), Fpin, '--k')
plt.plot(range(91), Fpout, '--k')
plt.show()


This is the complex number version of refraction, were K is the extinction coefficient. This is commonly used for metals.

You can check the Wikipedia on refraction: Complex refractive index | Wikipedia

• I have red that part of the article, but I fail to see the connection between that equation and the one I showed above. Perhaps my math skills arn't good enough to work that out. – Kristoffer Helander Jun 1 '17 at 15:44