1
$\begingroup$

Suppose I have a long equation with square roots and various trigonometric functions. Is there a way to approximate this function (over a fixed range) by curve fitting? My reading is that curve fitting is often used to regress over data points. In this case, the input would be a function though. Are there ways to force curve fitting use "simpler" integer functions? For instance, disallow the use of square roots or other irrational functions.

Any thought appreciated

$\endgroup$
4
  • $\begingroup$ You can calculate values of your function on an appropriate grid, then feed those to e.g. NonlinearModelFit. You will have to provide a model function to fit those points to, so you have full freedom to choose which functions appear in your model. $\endgroup$
    – MarcoB
    Dec 19, 2016 at 7:23
  • $\begingroup$ See FindFormula (or FindSequenceFunction). $\endgroup$
    – corey979
    Dec 19, 2016 at 8:20
  • $\begingroup$ Use FunctionInterpolation to get a piecewise polynomial interpolation. $\endgroup$
    – Szabolcs
    Dec 19, 2016 at 8:48
  • $\begingroup$ @Szabolcs I've just tried FunctionInterpolation, but how do I obtain the equation for the InterpolatingFunction object? $\endgroup$
    – John M.
    Dec 19, 2016 at 9:48

1 Answer 1

2
$\begingroup$

I am not very familiar with this area, but I think you may be looking for the FunctionApproximations package, or maybe PadeApproximant.

For example, let us approximate the function

f[x_] := Cos[x] + Sqrt[x]

with rational expressions on the interval $[0,2]$.

approx = EconomizedRationalApproximation[f[x], {x, {0, 2}, 2, 2}];
Plot[{f[x], approx} // Evaluate, {x, 0, 2}]

enter image description here

There are several other approximation methods in the package.

You may want to numericize the result using N[approx] // Simplify, as the exact coefficients are complicated.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.