# How to create algorithm for solving this problem?

Hello
How to create an algorithm to solve this problem :
Let's say we have the number 1,9,25,49,81
the formula xn = (2n-1)^2
That is, if n is to put the number 1 we will have the results too 1 and if n is put 2 the results will be 9 .
How to make a mini algorithm who would be in the water of numbers deduced the formula suppose we have 2,4,8,16,32 and I displays that xn =
Puzzled for a second day.
July 4th 19 at 23:11
July 4th 19 at 23:13
I think that the author meant an ordinary interpolation
well, what's the formula for a number 1 ; -2 ; 3 ; -4 ; 5 ? - ella.Feil commented on July 4th 19 at 23:16
What's the ranks? If there are values 1,2,3,4,5 and the value of the function at these points, for example, 1,9,25,49,81, you can easily obtain an interpolation polynomial - Erling_Hansen79 commented on July 4th 19 at 23:19
A little confused, you need an approximation - Erling_Hansen79 commented on July 4th 19 at 23:22
: approximation is another. Here the interpolation just. - Art_Christians commented on July 4th 19 at 23:25
Well, it the formula needed for the existing table-given function, this is just an approximation, and interpolation is finding the value of any f(x) inside the cut, and if cut out it is extrapolation. Isn't that right? - Erling_Hansen79 commented on July 4th 19 at 23:28
July 4th 19 at 23:15
What Is Lagrange ? What is interpolation ? It is the curriculum. But as correctly stated by colleagues, here we need to use neural network. Unfortunately they are not told what. I will say you need to use the network in your head, or the head of a neighbor.
P. S. bonus solution "... the number 1 ; -2 ; 3 ; -4 ; 5 ... " - formula: (-n)*(-1)^n
Do. I tried to first connect to the neural network of Google, but not found the answer. Then connected to the neural network in my head... and was surprised such a simple answer to solve the problem: xn = 2^n Wow! It's a geometric progression! - ella.Feil commented on July 4th 19 at 23:18
: I can't help thinking that the vehicle involved connecting to our neural network ... - Erling_Hansen79 commented on July 4th 19 at 23:21
: then I Interpol... hooked up their neural networks to your own, because your network accurately pointed out the solution to a similar problem :) - Erling_Hansen79 commented on July 4th 19 at 23:24
July 4th 19 at 23:17
Did something similar in the lab. Used genetic algorithms. But - directly for any set you won't get the exact formula. Especially depends on the allowed mathematical operators.
this 11th grade math and no one can resite ? - ella.Feil commented on July 4th 19 at 23:20
11 class? To find a formula for a number? Are you serious? No restrictions on input data? You are very wrong. - Erling_Hansen79 commented on July 4th 19 at 23:23
: Yes we have a theme , we are given a series of numbers and asked to find the formula , well I reshyl a few rows but the program is also able - Erling_Hansen79 commented on July 4th 19 at 23:26
OK, you find it how? Are there any rules? Most likely you are doing it with the TZ. programming a complete search. If you do something differently - then you should be the algorithm - Art_Christians commented on July 4th 19 at 23:29
: well, if I have a number of 1/2 ; 1/4 ; 1/6 I guess and check and it turns out that the formula 1/2n , where n is a number from 1 to infinity in dependence on the type of series - Erling_Hansen79 commented on July 4th 19 at 23:32
"suggest" is not algorithmically. The computer is not able to "assume". - Hans56 commented on July 4th 19 at 23:35
: well then, say so you can find the formula to a range 1; -2 ; 3; -4 ; 5 ? - novella_Hermiston36 commented on July 4th 19 at 23:38
I have told you about the option of genetic algorithm. This principle will work. - Hans56 commented on July 4th 19 at 23:41
: will take a very long time that he would have exhausted all your options - ella.Feil commented on July 4th 19 at 23:44
Analgorithm not sorted out all the options. Well, if you don't have any additional parameters on this line - what can you do. Limit mathematical operations, for example. Print a good evaluation function. - nicklaus commented on July 4th 19 at 23:47
: : I've read and wonder. Well riali, guys. It's easy. Just need an interpolation polynomial which at the points gives the exact value. Lagrange, the most simple. - ella.Feil commented on July 4th 19 at 23:50
: well, what's the formula for a number 1 ; -2 ; 3 ; -4 ; 5 ? - nicklaus commented on July 4th 19 at 23:53
: and Google and find the formula? We obtain a polynomial of the fifth degree) - ella.Feil commented on July 4th 19 at 23:56
: even -, odd +. Therefore: if (number %2 = no residue) { output: number} else { output: number}, with the exception of one. And all this wrapped in for, where i=limit - nicklaus commented on July 4th 19 at 23:59
July 4th 19 at 23:19
If it was possible, would have long since found the formula describing the pattern in a number of Prime numbers. But yet its such a formula.
Another thing is if you know which type of sequence, such as geometric, then the problem is reduced to the search (sorting) of the parameters of the function.
Do not mislead the unsophisticated friend, everything is there, as noted in the response above. - ella.Feil commented on July 4th 19 at 23:22

Find more questions by tags AlgorithmsC++JavaMathematics