# How to use math functions in the Calc Basic?

The documentations shows how to implement a basic VOL function:

``````Function VOL(a, b, c)
VOL = a*b*c
End Function
``````

So that I can write

``````=VOL(1,2,3)
``````

in a spreadsheet and get 6.

I want to write `arctan` which would return result in degrees instead of radians:

``````Function ARCTAN(rad)
End Function
``````

and call it as, e.g.:

``````=ARCTAN(1)
``````

This doesn’t work: Calc complains:

Sub-procedure or function procedure not defined

Can you help me to write this function?

See posting here.

Thanks. The example you linked is more of a [currying])(Currying - Wikipedia) though.

In this special case, you can use the internal functions of Basic. For a list of these functions see `Alphabetic List of Functions, Statements and Operators` in section `Command Reference` in tab `Contents` of the Help.

``````function ARCTAN(rad as double) as double
end function
``````

You need 45.0/atn(1) instead of 180.0/PI(), because PI() is not available as Basic-internal function.

`PI()` is not available but `Pi` works: `ARCTAN = atn(rad) * 180 / Pi`. Thanks!

Here’s a list of most used math functions: `atn/sin/cos/tan/exp/log/sqr/abs` plus a constant `Pi`. Source.

Original function does work in LO v5.1.3.2 the only difference from original question being atn() vs ATAN() and this thanks to @Regina.

Also in this versions’ off line Help, start with `Content` tab then `Macros and Programming`, `Command Reference` and finally `Alphabetic List of Functions, Statements and Operators`

Pi is actually used in the help example.

Changed "Answer’ to “Comment” - posted just for Help reference.