Best way to fit three functions

  • Context: Undergrad 
  • Thread starter Thread starter LCSphysicist
  • Start date Start date
  • Tags Tags
    Fit Functions
Click For Summary
SUMMARY

The discussion focuses on finding the optimal values of variables \(x, y, z, t\) for three highly non-linear functions \(f(x,y,z,t,n) = 0\), \(g(x,y,z,t,n) = 0\), and \(h(x,y,z,t,n) = 0\) using a limited dataset. The proposed approach involves minimizing the residuals for each function simultaneously, utilizing the Lagrangian method to manage the constraints. The discussion suggests employing Newton's approximation method or other root-finding algorithms to achieve a minimal sum of squared residues across all data points, emphasizing the need for a clear mathematical definition of "best fit."

PREREQUISITES
  • Understanding of non-linear function optimization
  • Familiarity with residuals and their minimization techniques
  • Knowledge of Lagrangian multipliers for constrained optimization
  • Proficiency in numerical methods, particularly Newton's approximation
NEXT STEPS
  • Research the implementation of Lagrangian optimization in Python using libraries like SciPy
  • Learn about Newton's method for root finding and its applications in optimization
  • Explore advanced techniques for minimizing non-linear functions, such as genetic algorithms
  • Investigate the use of WolframAlpha for visualizing function fits and data points
USEFUL FOR

Mathematicians, data scientists, and engineers involved in non-linear optimization problems, particularly those working with multi-variable functions and limited datasets.

LCSphysicist
Messages
644
Reaction score
163
TL;DR
I have basically three set of data, each set corresponding to a function, so that the data should fit the function, and each function is dependent of 4 parameters. How to find the best 4 parameters that fit it?
So I have $$f(x,y,z,t,n) = 0,g(x,y,z,t,n) = 0,h(x,y,z,t,n) = 0 $$ and i need to find the best ##[x,y,z,t]## that fit the data, where n is the variable. Now, the amount of data for each function is pretty low (2 pair for f (that is, two (n,f)), 3 pair for g and another 3 pair for h)

The main problem here is: the functions are highly non-linear. So i have no idea how can i write a program to find the best x,y,z,t!

I have thought of try to simultaneously minimize the residues, for example, for f:
$$R(f) = \sqrt{(f(x,y,z,t,n_1) - y_1)^2+(f(x,y,z,t,n_2) - y_2)^2}$$
(where y is the f obtained on thee data at n_1 (the pair i have cited above))

But this minimization subject to the condition that ##R(g), R(h)## (here, three terms) also be minimum. So maybe i could use Lagrangian method:
$$dR(h) = \lambda dR(g) + \mu dR(h)$$
But this is going to be extremelly massive and tedius to write a code, and the code will take days to run. As i said, the functions are non-linear.

Any method suggestion? or program suggestion?
 
Mathematics news on Phys.org
Extremely massive and tedious is probably the best you can get. If it was one occurrence, I'd advise WolframAlpha or plot the 3 functions and visually pick the best fit (further improved with Newton's approximation method).

For now I'd advise to combine the requirements for all the data points on f, g and h and rewrite them as ##function - data = 0## and then the square of the left hand side must be minimal for all data points simultaneously: so take the derivative with respect to ##n## of these squares all added up and approximate where this formula in ##n## equals 0 using Newton's approximation method or some better root finding algorithm.

Wiki on Newtons method
 
Last edited:
  • Like
Likes   Reactions: mfb
You'll need to decide what you consider "best fit". Write that down mathematically as fitquality(x,y,z,t), then feed it in a program for minimization.

The sum of squared residues for all data points (data point minus the applicable function) sounds like a good start.
 
  • Like
Likes   Reactions: Maarten Havinga

Similar threads

  • · Replies 0 ·
Replies
0
Views
530
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
Replies
3
Views
2K
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K