functionregRoot2
Anti-symmetric approximation of square root with discontinuous factor so that the first derivative is finite and continuous
Extends from Modelica.Icons.Function (Icon for functions).
Information
Approximates the function
y = if x ≥ 0 then sqrt(k1*x) else -sqrt(k2*abs(x)), with k1, k2 ≥ 0
in such a way that within the region -x_small ≤ x ≤ x_small, the function is described by two polynomials of third order (one in the region -x_small .. 0 and one within the region 0 .. x_small) such that
- The derivative at x=0 is finite.
- The overall function is continuous with a continuous first derivative everywhere.
- If parameter use_yd0 = false, the two polynomials are constructed such that the second derivatives at x=0 are identical. If use_yd0 = true, the derivative at x=0 is explicitly provided via the additional argument yd0. If necessary, the derivative yd0 is automatically reduced in order that the polynomials are strict monotonically increasing [Fritsch and Carlson, 1980].
Typical screenshots for two different configurations are shown below. The first one with k1=k2=1:
and the second one with k1=1 and k2=3:
The (smooth) derivative of the function with k1=1, k2=3 is shown in the next figure:
Literature
- Fritsch F.N. and Carlson R.E. (1980):
- Monotone piecewise cubic interpolation. SIAM J. Numerc. Anal., Vol. 17, No. 2, April 1980, pp. 238-246
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x | Abscissa value | |
| Real | x_small | 0.01 | Approximation of function for |x| <= x_small |
| Real | k1 | 1 | y = if x>=0 then sqrt(k1*x) else -sqrt(k2*|x|) |
| Real | k2 | 1 | y = if x>=0 then sqrt(k1*x) else -sqrt(k2*|x|) |
| Boolean | use_yd0 | false | = true, if yd0 shall be used |
| Real | yd0 | 1 | Desired derivative at x=0: dy/dx = yd0 |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | y | Ordinate value |
Contents
| Name | Description |
|---|---|
| Interpolating with two 3-order polynomials with a prescribed derivative at x=0 |
Revisions
- Sept., 2010
by Martin Otter:
Improved so that k1=0 and/or k2=0 is also possible. - Nov., 2005
by Martin Otter:
Designed and implemented.