Formula Guesser

y=mx+c

A program that looks at the shape of a provided series (or drawn curve), performs some analysis and then supplies you with an a number of formulae describing the shape of your curve to varying degrees of accuracy.

[edit] In other words, it would be neat to be able to draw bounds on a graph, around
some real figures, and have the machine give you a mathematical description of the lines and areas you just drew out.

-- zen_tom,
Sep 21 2006

Mathworks' Matlab

[Veho, Sep 21 2006]

"World series"

[phundug, Sep 21 2006]

Stalking the Riemann hypothesis

[Ling, Sep 22 2006]

Big Fat Prime Number

[zen_tom, Sep 22 2006]

SciPy.org: scipy.optimize.curve_fit

I discovered and have been playing around with this today - it probably predates the idea but is a really neat implementation for anyone who wants to try it out. What's especially forward-looking is that you feed it a base function along with the parameters that function requires, and it spits out a best-fit arrangement of those parameters based on a least-squares error metric. That means you can build your own plug-in functions to attempt to fit. [zen_tom, Feb 02 2017]

I have a funny feeling in my bones that there are existing algorithms that do this... unfortunately I lost the manual for my graphics calculator about 9 years ago (less than 1 year of having the calculator).

I think it has a curve fitting function of some kind...

<looks at machine, presses some buttons>

Unfortunately the closest I can manage is making words upside down... 58008

-- Jinbish,
Sep 21 2006

710 0553 - hmmm. Excel can perform linear analysis (i.e. numbers in a series follow discrete steps of 1 or 2 etc) but I don't think it's any cleverer than that.

I'm trying to write a program that will output the nth prime number. I already have a program that gives me all the prime numbers below a given number y (it's an Eratosthenic Seive). What I want to do in determining the nth prime is to kick off the Eratosthene program, giving it an appropriate value for y (too small and you never generate the nth prime, too high, and you're wasting processing time generating unnecessary numbers) So I've graphed up the first 300 or so prime numbers, and am looking at the curve it makes. It looks fairly regular from a distance (but deviates horribly the closer you look at it) and I ought to be able to use a formula that defines upper and lower bounds so that even if I don't get y spot-on (an unlikely scenario) I'll be fairly close, thus minimising any wasted calculations. The important thing is that whatever formula we eventually use, it has to project into unknown number-space and still perform its task.

It would be neat to be able to draw bounds on a graph, around some real figures, and have the machine give you a mathematical description of the lines and areas you just drew out.

-- zen_tom,
Sep 21 2006

07734 Excel will give you the formula. Enter the seties, graph it and it will (optionally) display the formula. It is somewhat limited, but at face value it does what you are asking, or are you asking for more?

[Edit] 'seties'? - extra-terrestrial data sets? Sp: series

-- Shz,
Sep 21 2006

53045 - I've just looked everywhere - how do I get Excel to tell me what formula is hiding behind a perfectly good series? I know it can figure out linear series (probably a better word for that) where each number is the last number +1, or +5, or +25 etc - but what we want is something that can deal with squares, inverse 3rd powers, binomials, polynomials and any other kinds of gnomials that might present themselves. My curve looks fairly simple, it starts at zero, has a gradient of between 0.3 at the low-end, 0.122 at the higher end (at around n=300) and a mid-point gradient of around 0.152 in the middle (n=150 or so). I don't know, but I imagine that it will behave fractally (i.e. whatever zoom you use, it should look similar) and therefore, there ought to be a nice heuristic formula for this shape - but I can't get Excel to tell me what it is (and I refuse to ask the Paperclip)

-- zen_tom,
Sep 21 2006

The "fminsearch" function of the technical computing program Matlab is used to find a function that best approximates a given curve/graph. It is an iterative process, in which it changes coefficients of the function slightly, and finds the local minimum of the difference between the given graph, and the graph of the approximation function. The ideal minimum would be zero. After several tries from several starting sets of initial coefficients, you get a global (overall) minimum, and the set of coefficients you get for that minimum represent the best approximation of the curve as a function.

-- Veho,
Sep 21 2006

Spookily - I have just had MatLab installed on the PC that I type...

-- Jinbish,
Sep 21 2006

In Excel:

Enter the data in a column

Select the data

Click the chart wizard icon

Select XY (scatter)

Click next, next... finish and it creates a graph

Right click a data point on the graph

Click 'Add Trendline' from the drop down

Select the trend/regression type (and order for polynomials, etc.)

Click the options tab

Check 'display equation on chart' (and R^2, etc.)

OK

-- Shz,
Sep 21 2006

zen_tom, I am currently reading "Stalking the Riemann hypothesis". The first part of the book goes into detail about the various efforts to find a curve fit to the number of primes in the natural numbers. It also explains the largest number with any meaning in mathematics, where one curve fit was proved to cross over with the real trend. The number was much bigger than the total number of particles in the known universe.

See link for the book reference.

There is a proof for the infinite quantity of prime numbers which was very neat and simple. It finally proves that any larger prime number can be made by simply multiplying a running series together and adding 1. For example (3x4)+1=13 and (3x4x5x6x7)+1=2521. I can't remember if it was supposed to start with 2, but (2x3x4)+1=25, which is not prime, so I guess it doesn't. This doesn't tell you every prime number, unfortunately.

-- Ling,
Sep 22 2006

Thanks, [Shz], you learn something new everyday - I can announce that y = -6E-16x^5 + 2E-11x^4 - 2E-07x^3 + 0.0012x^2 + 6.9584x (apparently) is the final equation that appears to fit the trend. I might investigate a little more. That (series)+1 sounds similar to something else I was looking at, the largest known primes are known as Mersenne primes they are the primes that can be generated using the formula (2^n)-1 (I've linked to one that's 7,235,733 digits long)

-- zen_tom,
Sep 22 2006

[Ling], that's not quite right - for example, 3*4*5*6*7*8*9 + 1 = 181441, which is divisble by 13.

The proof works when you multiply a running series *of prime numbers* together (starting with 2) before adding 1. Since the new number is not divisible by any smaller prime numbers, it must itself be prime.

-- imaginality,
Sep 22 2006

imaginality, Ah, yes. I knew it was a series of *something*, checked a couple of cases, and then forced 2+2 to equal 5. Sorry about that.

-- Ling,
Sep 22 2006

This is long baked and widely known to exist. And it's a bit of a wouldn't-it-be-nice, as it doesn't suggest how it's to be done, so, [MFD removed]

-- ldischler,
Sep 22 2006

[imaginality] It is a series of prime numbers, but each number to a certain power, for example,
every whole number N can be represented by a quotient, N = p1^a1*p2^a2*...*pn^an, with the values of each "a" between 1 and infinity, and the primes are all the prime numbers smaller than a.
If a number can't be represented by such a quotient, it is a prime number. (N+1, for example)

-- Veho,
Sep 22 2006

I'm not sure that's exactly the case [ldischler]. While we've shown that Excel (among others) can figure out a trend type formula based on a provided series of data, it's still an overly technical process - I still don't see anything that will do this for a hand-drawn (or Bezier for example) curve.

I want to be able to swoop lines about in a visually meaningful sense, and have the computer output the maths for defining the lines and areas that I describe.

The reason I haven't described the process is because I haven't the slightest idea of how, what I do know however, is that it is implementable - as proven by the clumsy implementations described here (as well as many of the popular vector-based graphics formats in existance)

-- zen_tom,
Sep 22 2006

Okay, the problem is really just digitizing the data, which can be done on a digitizing pad, or by drawing on-screen with drawing software (what looks like a curve is internally represented by a set of points). That's stuff is well known, and regression is also well known, but software that automatically combines the two? It obviously exists, as curve fitting exists on almost all engineering drawing software, but are there any that will give you the formula? As I don't know, I'll remove the MFD.

-- ldischler,
Sep 22 2006

The program "CurveExpert" does this essentially automatically. Unfortunately it's Windows-only.

-- CRGreathouse,
Sep 01 2009

Just as an aside:

//proof works when you multiply a running series *of prime
numbers* together (starting with 2) before adding 1. Since
the new number is not divisible by any smaller prime
numbers, it must itself be prime.// Not quite. The product
must *either* be prime itself *or* must be the product of two
or more prime numbers larger than the largest member of
the series. Hence, there must be a larger prime than the
largest member of the series.

-- MaxwellBuchanan,
Sep 01 2009

random,
halfbakery