# 4.2.2.19 Quoting Built-in Functions in Your New Function

## Summary

This tutorial will show you how to reference a built-in function when creating a user-defined fitting function.

Minimum Origin Version Required: Origin 8.0 SR6

## What you will learn

This tutorial will show you how to:

• Define a piecewise fitting function
• Access built-in functions in you new function
• Auto initialize the parameters

## Steps

### Data

Start by importing the file \Samples\Curve Fitting\Asymmetric Gaussian.dat into a new workbook.

Highlight column B and create a graph. The peak in the data is slightly skewed to the right. How to fit such a curve? One idea is to divide the curve into two parts - We can consider this curve to be composed of two Gaussian function as below. These two Gaussian curves share the same baseline and peak center, but differ in peak width and amplitude. ### Define the Function

Press F9 to open the Fitting Function Organizer and define the function as below:

 Function Name: AsymmetricGauss Function Type: User-Defined Independent Variables: x Dependent Variables: y Parameter Names: y0, xc, w1, w2, A1, A2 Function Form: Origin C Function: y = x
 Note: For versions before Origin 8.1, the function body should be defined as: y = x

When calling nlf_FuncName to reuse built-in functions, the syntax is:

nlf_FuncName( independent variable, parameter list ... )

where FuncName is the fitting function name. Besides, the old notation, nlfxFuncName also supported.

The Parameter List follows the parameter order in function definition file for the built-in function (the FDF file. You can open the FDF file in Notepad. The files are located in the \\Origin EXE Folder\FitFunc\). Note that, the function name we use is the DLL interface name. The actual name in the [General Information] section of the FDF file. Look at the Function Source item and the value is fgroup.FuncName, and use the FuncName. In most cases, this function name is consistent with the function name visible in the NLFit dialog. For a few few functions such as Voigt, these names are different.

For parameter initialization of this skewed gaussian function, we can simply copy the initialization code of the built-in gauss function, and make a few minor modifications:

xc = peak_pos(x_y_curve, &w1, &y0, &A1);
w2 = w1;
A2 = A1;`

The final function body should be as below: Once compiled successfully, save the function and fit the curve. The results should be as below:
{"ft_lang_label":"__label__en","ft_lang_prob":0.74531317,"math_prob":0.8226902,"size":2853,"snap":"2021-21-2021-25","text_gpt3_token_len":724,"char_repetition_ratio":0.15514216,"word_repetition_ratio":0.012578616,"special_character_ratio":0.2429022,"punctuation_ratio":0.17301038,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9574469,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,10,null,10,null,10,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-19T18:52:47Z\",\"WARC-Record-ID\":\"<urn:uuid:8ea18c42-85eb-46b2-8ed4-3bf64be9cc51>\",\"Content-Length\":\"140905\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:02f0332c-3174-403b-ae77-4f2c2f0c7902>\",\"WARC-Concurrent-To\":\"<urn:uuid:1499b6cd-682d-40a6-b912-34029f5ace80>\",\"WARC-IP-Address\":\"13.249.32.131\",\"WARC-Target-URI\":\"https://cloud.originlab.com/doc/Tutorials/UDF-Quote-BuiltInFunc\",\"WARC-Payload-Digest\":\"sha1:GJU23SALMWCJ3665SICOTLXR6UMHNVZA\",\"WARC-Block-Digest\":\"sha1:KFPXBOS62MCFIJ5IXSWSQS3KTFVWSYD5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623487649688.44_warc_CC-MAIN-20210619172612-20210619202612-00017.warc.gz\"}"}