finding source function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

finding source function

Can I find approximately function expression when I know arguments and relevant function result. For instance i have this sample : f(1)=3 f(2)=5 f(3)=7 then when I think a little bit, can I realize expression of function is x*2+1 So, how I can automate this process ?

31st Oct 2019, 2:30 PM
maskkskf wseggw
maskkskf wseggw - avatar
4 Answers
+ 2
https://en.m.wikipedia.org/wiki/Linear_regression Basics of statistics. You have a bunch of data points, you can always define a linear regression formula to approximate the function. The essence of the method is to find the coefficients that minimize the error. Clearly this would not really work well, if the function is not close to linear...
31st Oct 2019, 8:42 PM
Tibor Santa
Tibor Santa - avatar
+ 1
What if it isn't ? 3, 5, 7 can also be seen as a serie of prime numbers, with f(0)=2. There are infinite number of functions that can have the same output, so I don't think there is any efficient program to do that. If your original function is polynomial, then there are few ways to do so (search on google, I don't know how to)
31st Oct 2019, 2:35 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
It's was just example, not matter. There one other: f(1)=1 f(2)=4 f(3)=9 then program have to respond something like this f = x^2
31st Oct 2019, 2:44 PM
maskkskf wseggw
maskkskf wseggw - avatar
+ 1
I know one sequence can generated by infinity ways if we not have all they numbers. But I sure It's possible find source function. For example we can define simple function in certain segment but I have not ideas how to do it
31st Oct 2019, 2:55 PM
maskkskf wseggw
maskkskf wseggw - avatar