# Can I add Functions to Math?

I'd like to add a function to LO Math, specifically arctan2(y,x), but in the menus I found no way to do this.
Is this even possible?

Thank You.

edit retag close merge delete

This function is present in Calc. It is listed as ATAN2

( 2021-02-28 21:53:58 +0200 )edit

I'm aware of this. But I'm talking about Math and adding it as a function to present formulas using it in a nice way.

( 2021-02-28 22:04:05 +0200 )edit

Something is a bit munged with the forum here. Wanted to edit my comment or add a new one and couldn't mouse pointer moved a bit and hit the convert to answer link.

Yes you did say Math... Looks like you will have to build that function as a macro and call it that way.

Also has anyone else noticed that in the Math module of LO is called Formula in the File/New drop down menu?

Using LO 7.0.4.2 from opensuse 15.2.

( 2021-02-28 22:17:58 +0200 )edit

Do you mean make arctan2(y,x) to look like other functions, as in arctan2(y,x)? Put double quotes around it, "arctan2"(y,x)

( 2021-02-28 23:30:47 +0200 )edit

You would prolly want to make it look and work like a normal function would. I've not personally done this, but it should be possible with a macro. This will be a good start on macro writing https://duckduckgo.com/?t=ffab&q=libr...

( 2021-02-28 23:38:25 +0200 )edit

Aren't the function ATAN2() and its name monsters anyway. All my life I worked with functions named without the usage of digits. Calc (or whoever) didn't a good job with that function giving it a name outside the usual namespace for functions. In addition AZAN2() is completely needless. Math shouldn't be blamed for "disliking" names with digits.

( 2021-03-01 00:39:09 +0200 )edit

Why are you talking about Calc? Riding some hobby horse here?
The question was related to Math.
https://en.wikipedia.org/wiki/Atan2

( 2021-03-01 00:50:49 +0200 )edit

You're kidding? Of course I knew the question was about Math.
However, a function named atan2 (and its functionality) simply isn't known to me except for spreadsheets. Why should it be used in a Math formula then? In mathematics the nearest related function would be arg where the input which is a pair (x, y) for the spreadsheet function would be the complex number x + i y.

( 2021-03-01 02:03:31 +0200 )edit

atan2/arctan2 is a well-known function distinct from atan. The latter takes a single "tangent" argument (and has no way of knowing which half of plane is being meant), while the former takes two arguments (coordinates of a point on the tangent ray) to overcome this limitation of plain atan. Distinguishing the two functions is very useful, and blaming others in wanting to use such things (based on something "isn't known to me") is ... strange. Besides, even if it were used only in spreadsheets (which is not the case), why would someone not want to create, say, a tutorial for spreadsheet use with formulas created in Math? And should that someone give you account for their reasons?

( 2021-03-01 07:29:46 +0200 )edit
1

I see the distinguishing of inlined digits as a regression. This is the kind of "second guessing user intention" which is an important reason why I dislike MS Office.

I submitted an "un-enhancement request"

( 2021-03-01 10:11:31 +0200 )edit

Sort by » oldest newest most voted

If you need a new "function" in Math, just use

func newfuncname(x, y)


... which would format the argument of the func keyword according to your formula's functions setting (same formatting as, say, sin built-in function).

It seems that the 2 is automatically considered an argument to the new function, and will be formatted as number (it's common to have things like sin45°); so for arctan2, you might need a workaround like

func arctan func2(y,x)


or, taking into account that arctan is already a pre-existing function, and Math inserts a small gap between function name and argument, it might even be better to use this:

nospace {arctan func2}(y,x)


The keyword is present in the Math' Functions section of Elements pane:

more

See tdf#140726 which I filed for possible discoverability problem with this keyword.

( 2021-03-01 08:19:11 +0200 )edit

Thank You for your efforts. Your suspicion that 2 is formatted as a number is correct, so I'll stay with my Text/italic workaround.

( 2021-03-01 18:30:22 +0200 )edit

OK, solved somehow.
Entering the function as "arctan2" and choosing 'Format', 'Fonts..', 'Modify', 'Text' and choosing italic makes it look good.
Using a macro is somewhat over the top.

Math is a bit of a stepchild in LibreOffice, I think. But nice.

more