The mathematical graph to the equation

Is there a tool that converts the graphical representation of an equation into this equation? (Graphical representation for a mathematical equation)

+6
math graph
source share
3 answers

This is a complex problem, commonly called interpolation . For simple polynomial graphs, this is a simple task. (You can always find an “exact match.”) See polynomial interpolation . But you can also have a graph representing some trigonometric function. Or what about exponential functions or logarithmic functions. Or, even worse, combinations! Even for simple graphs, there can be thousands of interesting potential equations.

Even if you check all the interesting equations, you should still be careful. Consider the equation y = A * sin(B*x) with extremely large values ​​for A and B What does this chart look like? Well, he rises and falls again and again between A and -A , really really fast, and “hits” or “almost hits” at almost every point. This is a “simple” formula that mathematically looks like a good approximation, but it is still probably not what you need at the end.

+2
source share

A common problem that may fit your description is called curve fitting : you have some data (which in your case you read from the graph), and you mean the form of the equation, and you want to find what parameters you need to best match the equation on the graph.

A useful approach to this is suitable for least squares error. The Least Squares package will be available in most data analysis toolkits.

Here is an example: let's say the equation is A * sin (2 * pi * 100.x) * x ^ B, and I need to find the values ​​of A and B that give me the best fit (A = 10.0 and B = 3.0 in this example).

alt text

Here is the code used to generate this match. It uses Python and Scipy and is modified following the example here .)

 from numpy import * from scipy.optimize import leastsq import matplotlib.pyplot as plt def my_func(x, p): # the function to fit (and also used here to generate the data) return p[0]*sin(2*pi*100.*x)*x**p[1] # First make some data to represent what would be read from the graph p_true = 10., 3.0 # the parameters used to make the true data x = arange(.5,.5+12e-2,2e-2/60) y_true = my_func(x, p_true) y_meas = y_true + .08*random.randn(len(x)) # add some noise to make the data as read from a graph # Here where you'd start for reading data from a graph def residuals(p, y, x): # a function that returns my errors between fit and data err = y - my_func(x, p) return err p0 = [8., 3.5] # some starting parameters to my function (my initial guess) plsq = leastsq(residuals, p0, args=(y_meas, x)) # do the least squares fit # plot the results plt.plot(x, my_func(x, plsq[0]), x, y_meas, '.', x, y_true) plt.title('Least-squares fit to curve') plt.legend(['Fit', 'Graph', 'True']) plt.show() 
+2
source share

I saw some tools that fit the equations for graphs in images, but I can't remember their names right now. A quick Google search showed this commercial application: http://imagedig-2d-3d-image-digitizer.smartcode.com/info.html

+1
source share

All Articles