Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Developing a program for finding functions

Developing a program for finding functions

Developing a program for finding functions

Hello everyone,

I am an intermediate at FORTRAN and want to discuss the main idea of my next project before I begin. Basically I am going to program a function finder for simple, one-dimensional functions in the first place. Later I plan to extend it to higher dimensions. The pseudo-code is as follows:

1. Read in an array from an external file with given x- and y-values of the unknown function (DONE)
2. Generate a possible function.
3. Check the differences of the given values and calculated values of the function. If this global error is below a certain value (1E-5 or so) the function is found. If not, go back to 2. (DONE)

As one can see I have difficulties with point 2:
I want to generate all possible functions for the given problem successively. Lets suppose I only know that the function depends on one variable (x). It may contain brackets and all possible arithmetic operators.

What I want to know is: How can I realize it to try out all arithmetic operators and brackets at every digit? At an arbitrary point the program should generate the following functions for example:


This might be not be the best example, because some expressions are equivalent, but that does not matter here. I hope this example points out what I want to realize. Is the conversion of a generated string into a function a good idea?

Is it at all possible to develop a code, which
- generates a string where
- all possible function elements (numbers, arithmetic operators, brackets...) are tried out at every digit,
- then this string is converted into a function, which is used for the calculation in step 3 (see above)?

Some hints or other ideas how to realize this are welcome.

I am aware of the fact, that each function must be checked for correctness at first to avoid runtime errors, means the number of opening and closing brackets must be the same, arithmetic operators are not allowed to follow on each other, between two brackets should be one operator with two other values at least and so on. Furthermore all senseless possibilites can be skipped to increase efficiency.

Thanks for reply,
Daryl Musashi

RE: Developing a program for finding functions

You say that you want to generate all possible functions... You cannot. You have to choose one or several function forms (many are possible) with parameters and you have to adjust the parameters...

For instance, a possible form could be polynomial : a0 + a1*x + a2*x^2 + a3*x^3, but a serie of cosinus or sinus functions is possible too (see Fourier).
Then, for a given table, you can find the best parameters fitting the table (least square method for instance).

Another direction could be the approximations by NURBS. Non Uniform Rational Bezier Splines are the way to model complex curves or surfaces with a minimum set of construction points. The result is not analytical (you still have a table of points) but you can manage the final smoothness as you want (NURBS of class C1, C2 ...). The advantage of the NURBS is that you can adjust the number of constructions points to match the initial table.

Fran├žois Jacq

RE: Developing a program for finding functions

There is an ANCIENT fortran program called "Linear". This function would provide you with the (again) ARCHAIC code which easily forms the basis of such a project.

This was "once upon a time ... in a land far away ... available from Oak Ridge National Laboratory
under contract # W-7405.eng-26 as ORNL4264

There was also a FOTRTAN IV program listing. The entire program source code was ~~~ 400 lines.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close