# How can I determine a function equation from a graph image?

How can I find out the function equations in a diagram with 5 curves? Measuring by hand is very inaccurate and takes a lot of time. Any other possibilities?

• My personal favorite tool is DataThief datathief.org . There are, as mg4w wrote, many other software tools for extracting values from graph images Mar 11 '16 at 15:58

## 2 Answers

I don't know how this function was obtained (or what it is supposed to represent). But you could try searching the literature to see if someone has published equations of the curves. However, looking at it I would suspect that there is not a straightforward expression for these curves.

The best option I can think of is to use graph digitization software to extract the data, then use a curve fit to obtain an equation for each line (lots of software can do this: Excel, MATLAB, etc). By this method you could get at least as much accuracy as reading values off the graph, and it could then be included in a computer program.

• If you do curve-fit in Excel, you can plot the $R^2$-value of the curve generated to get an indicator of its accuracy too (closer to 1.0 is better). I haven't used MATLAB, so I can't comment on its usage. Mar 10 '16 at 19:14
• Also, found this related Question on Stack Overflow. Mar 10 '16 at 19:17
• $R^2$ is overrated, and tends to be misunderstood by all but expert statisticians. But in any case, you can get $R^2$ and plenty other quality parameters from R, Matlab, numpy, etc. Mar 11 '16 at 16:00
• For extracting the data, you can also take a look at the answers to related questions on Academia.SE and Stats.SE. Apr 4 '16 at 8:04

You have a single-valued function dependent of two variables. There are many ways to model that.

If you know something about what this function represents, then going back to the physics might yield a useable equation with only a few coefficients. Digitize a bunch of points, throw them at a least-squares error minimizer and see how close the result is.

If you know nothing more about the physics behind the function, then the standard answer is a polynomial. From the general look of the curves, I'd say you need at least a 3rd order polynomial (a cubic). With two independent variables and the various crossover terms, that comes out to 10 coefficients to adjust to get these curves.

Either way, I'd digitize 10 values for each curve, one where they hit each marked X division. It really wouldn't take long to just sit down and do it. That gives you 50 points, which should do a reasonable job of allowing a least-squares error solver to divine the coefficients for you. For the polynomial case it would be trying to solve for 10 value. In the physics modeling case, hopefully fewer.