Custom Functions

Custom Functions

Define your own fitting function as a plain-text expression, using standard operators and function names, with any number of fitting coefficients.

CFTool lets you define custom fitting functions using standard mathematical operators and function names. Custom functions are entered as plain-text expressions and can include any number of fitting coefficients.

01Basic syntax rules

  • Always include explicit arithmetic operators — write a*x, not ax.
  • Functions must use parentheses, for example: exp(), sin(), arcsin(), sinh(), arcsinh(), log(), ln(), sinc(), abs().
  • As of CFTool Version 7: log10() is logarithm base 10, while log() or ln() is the natural logarithm (base e).

Logarithm change in Version 7. In earlier versions log() was base 10 and ln() the natural logarithm. The new behaviour keeps custom functions consistent with the spreadsheet formulas introduced in Version 7.

02Powers and roots

Use the caret symbol (^) for powers:

x^2   x^3   x^1.5   x^(3/2)

Square roots can be written as sqrt(x), but other roots should use fractional powers — for example x^(1/3) is the cube root of x.

03Negative signs and constants

Negatives are written in the usual form: -b or -(x/a).

The constant π is recognised automatically — enter it as pi, which CFTool interprets as 3.14159…

04Coefficients and variables

  • Any standalone letter or letter/number group such as a, b, c2, k1 is treated as a fitting coefficient.
  • The letter x is reserved as the independent variable and should not be used as a coefficient name.
  • A coefficient may appear more than once in the same expression — CFTool recognises and links the occurrences automatically.

05Example

Expression: a*exp(-(x/b)^c)*sin(d*x+e)

Detected coefficients: a, b, c, d, e

When you apply this function, CFTool lists these coefficients in the Fitting Coefficients window, ready for initial values or constraints.

06Checking your function

After entering a custom function and clicking Apply, the Fit Options window appears. Check that all the coefficients you expected are listed.

  • If any are missing, there is likely a syntax issue or an unrecognised function in your expression.
  • Review the function for missing operators, parentheses or typing errors.

07Tips for reliable functions

Good practice

  • Include parentheses to make operator precedence clear.
  • Keep the expression compact but readable — avoid excessive nesting.
  • Start from a simple form and test it before adding extra terms.
  • If CFTool reports an unrecognised symbol, check spelling and make sure every coefficient is separated by an operator.
  • Remember that trigonometric and exponential functions expect radians and natural exponentials (base e).

08Built-in function reference

Category Functions Notes
Arithmetic / algebraic abs(x), sqrt(x), pow(x,y) Basic numeric operations
Exponential / logarithmic exp(x), log(x), ln(x), log10(x) log and ln are natural logs; log10 is base 10
Trigonometric sin(x), cos(x), tan(x) Input in radians
Inverse trigonometric arcsin(x), arccos(x), arctan(x) Range –π/2 to π/2 for arctan
Hyperbolic sinh(x), cosh(x), tanh(x) Standard definitions
Inverse hyperbolic arcsinh(x), arccosh(x), arctanh(x) Real-domain limits apply
Special sinc(x) Normalised sinc = sin(πx)/(πx)
Constants pi π = 3.14159…

Unrecognised function? CFTool warns you when you click Apply Custom Function — check for spelling or missing parentheses.