Ask Your Question
1

how to join functions with an intermediate fit to obtain smooth derivatives

asked 2020-10-14 14:05:17 +0100

gg@g gravatar image

updated 2020-10-14 14:05:36 +0100

I want to modify a function which contains a pole for numerical simulations, e.g. limit it to a maximum value around the pole. My idea is to connect two original functions f1 and f2 (e.g. one with pole and one constant) with an intermediate fit function between two x values x1 and x2. The fit function should continue the two original functions between x1 and x2 as well as their first two derivatives, and it should be monotonic in this range.

I found some hints how to fit (x,y) points with a lagrange_polynomial or find_fit to match a given function template, but these approaches do not seem to be extendable to fit the derivatives at the same time, e.g. fit points from (f1,f1', f1'') and (f2,f2',f2''). At least this seems to me what needs to be done. Is this a feasible approach, and how can it be solved?

Constructing a set of splines between x1 and x2 might be an alternative, but the implementation in the simulation system would be more complicated compared to a single polynomial. I guess 3 spline segments might be sufficient to create a "connector template", but a subsequent fit of a single function to this set of splines (to obtain a simpler implementation for the simulation) would probably violate the continuity of the derivatives, and I worry that construction of suitable intermediate points to obtain a monotonic fit function is another complication. Thus, again, this seems to result in a general multi-function fitting problem to which a genius may have found a general approach already?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-10-15 09:54:00 +0100

eric_g gravatar image

Probably, you are looking for Hermite interpolation. For interpolation up to the first order derivative, you can use SciPy's CubicHermiteSpline, which is available in SageMath:

sage: from scipy.interpolate import CubicHermiteSpline                                              
sage: CubicHermiteSpline?
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-10-14 14:05:17 +0100

Seen: 272 times

Last updated: Oct 15 '20