# How do I calculate this error?

I'm not sure if percent error is what I want here. I know that percent error is defined as

$PE = \frac{\text{experimental}-\text{theoretical}}{\text{theoretical}}*100$%

...so this won't help with my problem.

I an experimental and a theoretical value. I want to see how close I am to the theoretical value by returning a value between $0$ and $1$ where $1$ means I reached the exact theoretical value and the return value never reaches $0$, it only gets smaller and smaller, meaning that it represents a worse and worse value.

I tried using $\frac{\text{experimental}}{\text{theoretical}}$, but the problem here is that the experimental value can be much larger than the theoretical one and I don't want to the return value to be much greater than $1$.

What formula am I looking for here?

• I don't know is there any generally agreed upon way to do this. If I needed to do something like this I might have a Gaussian distribution of maximum 1 around the theoretical value. – mtheorylord Jun 2 '17 at 2:40

$$d_1(x,y)=\frac{2(x−y)}{|x|+|y|}.$$
This is a signed expression, positive when $x$ exceeds $y$ and negative when $y$ exceeds $x$. Its value always lies between $−2$ and $2$ .
So you can use $$d(x,y)=\left|\frac{Experimental−Theoretical}{|Experimental|+|Theoretical|}\right|,$$ to acheive a value between $0$ and $1$.
Also, a Wikipedia article on Relative Change and Difference observes that $$d_\infty(x,y)=\frac{|x−y|}{max(|x|,|y|)}$$ is frequently used as a relative tolerance test in floating point numerical algorithms.
So you can use $$d(x,y)=\frac{|Experimental−Theoretical|}{max(|Experimental|,|Theoretical|)},$$ to acheive a value between $0$ and $1$.