How does Wolfram Mathematica solve curve fitting problems? - matrix

Is wolfram mathematica able to find type of curve ? If yes , what function is used ? Also is there any function to solve least square problems in matrices ?
I tried to find some functions in the wolfram Mathematica documentation yet, I couldn't find a suitable one.

Related

Genetic programming for symbolic equation solving

I'm trying to perform a genetic programming system which solves an equation (basically first and second degree polynom equations) symboliclly.
It means that for a*x+b=0 it must give me a tree representation of -b/a. What i mean by symbolically is that i'm not giving numbers for 'a' and 'b' ... basically what Generic Programming are made for.
I'm actually stuck in finding the fitness function. For a given gene (potential solution), how can i predict how far is this one from the right solution.
My doubt is that there's no way to do such a thing unless i convert the problem into a numerical one.
I've been searching in the net, but all i found was related to genetic algorithms and so numerical resolution for such problem.
a link exposing such topic is found here: Generic Programming but it's not explaining a detailed approach about the problem.
Any ideas ?
Thanks in advance.
I've finally found a solution.
I've found a powerfull library which is designed for Genetic Algorithms for java developpers, and have a module specialized in Genetic Programming (GP).
Library's link: Jenetics
My implementation of the solution is available on my github at this link: Symbolic Equation Solver
It's basically a Maven based project, which makes use of Java 11 and the above library to solve Linear and Quadratic equations and gives symbolic (and not numeric) result.

lapack library in codeblocks, boundary value

I am a student from Germany, currently doing the master thesis. In my master thesis, I am writing a Fortran code in code blocks. In my code, I am using some of the LAPACK functions.
I want help regarding adding LAPACK library in code block software. I searched a lot on the internet but I couldn't find anything. It'll be better if you provide me all the source links extension of the previous question.
In my code, I need to solve the following system of equation, {K}{p} = {m}
Where
{K} = Matrix
{p} = vector
{m} = vector
I have all the elements of vector {m} and matrix {K} computed and I have some known values of vector {p}. It's boundary value problem.
Now I want to find out only unknown values of elements of a vector {p}.
Which function should I use?
I went through the LAPACK manual available online but couldn't find.
Well you did not go through the documentation so thoroughly :) You are looking for solvers of a linear equation.
http://www.netlib.org/lapack/lug/node38.html
Please specify a little more about complex/real double/float. ill posed? Over or under determined or quadratic? If quadratic then symmetric or upper triangular? Banded?
There is a hord of different algorithms one would consider. Runtime / stability / convergence behaviour are very different dependent on K. The most stable would be [x]gelsd. It's a divide and conquer algorithm via SVD and gives you with proper conditioning the moore penrose generalised inverse. But it is by far the slowest algorithm too.
btw, http://www.netlib.org/lapack/lug/node27.html, outlines all general solvers.
If you already have some values of your p, you would like to go a different route than a straight forward inversion. You are a lot better off, if you use an iterative method like conjugate gradient least squares problem with regularization. This is discussed in length in Stoer, Bullirsch, Introduction to Numerical Analysis, Chapter 8.7 (The Conjugate-gradient Method of Heestens and Stiefel).
There are multiple implementations online. One you will find in a library I wrote during my PhD: https://github.com/kvahed/codeare/blob/master/src/optimisation/CGLS.hpp

Curve Fitting - DataSet

I am given the following problem.
I have a Set of functions which are linear combinations of the following functions (f1,f2,f3....fn) and a noisy dataset of pairs (x,y). I want to find a function from my set which approximates the dataset the best.
They key to finding the solution is to find coefficients a1,a2...an so that the resulting function f=a1*f1...an*fn approximates y well given the input x. If the data wasnt noisy, I could just choose 5 points and solve the resulting system of equations but I dont think this would work well with noisy data.
How would one find the coefficients ?
(I am asking for an algorithm and not for a program, for example matlab, that does the job for me)
In presence of noise you need to find some approximation solution, that minimizes discrepancies with ideal solution.
Such best fit problems are usually solved by optimization algorithms.
Widely used one is Levenberg–Marquardt algorithm.

how can i find an analytical expression ? findfit ? MATLAB

Supposed that i have
fu3 = g.^5.*qQd./(exp(g.^2/T(i)));
I_value = (1/T^3)*trapz(g,fu3);
so, that depends of T and s ( included in qQd ). This calculation take a several minutes. So i want to fit this expression into a easy polynomial expression. I Think the name is fit or interpolation. I want to find a polynomial expression that satisfy my integral of I_value. Any help ?
What's your integration range? Let me assume it is pretty large. Then your integrand function varies by many orders of magnitude (did you plot it? probably you need logarithmic scale to understand the full extent of the problem). This is the cause for trapezoidal integration taking minutes. Replacing the integrand by a polynomial is not an option here.
Solution 1: Solve the problem analytically (partial integration, and substitution g^2->u).
Solution 2: If nevertheless you want to do it numerically, use a better integration scheme than equidistant trapezoids. You need an integrator that adapts step width according to magnitude variations of the integrand.

Numerical Solutions in Maxima

I have an equation in maxima and I want to find a numerical solution to the variable in this equation. I was wondering if anyone knew a what function in maxima operates most similar to that of FindRoot in mathematica?
There seems to be a couple of ways to do it but I am hoping to check results against that of a mathematica code, hence why I am interested in something similar to FindRoot.
Ben
Mathematica's FindRoot searches for a numerical solution. The closest thing in Maxima (AFAIK) is find-root, which finds a numerical solution in a given interval.
Example:
(%i4) find_root(x^2=7,x,0,100);
(%o4) 2.645751311064591

Resources