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.

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

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.

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.

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)

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=libreoffice+macros&ia=web

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.

Why are you talking about Calc? Riding some hobby horse here?
The question was related to Math.
For your reference:

1 Like

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.

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?

1 Like

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”

Oh so it’s not like it always was before? Nice find @keme - then it’s a regression.

Oh so it’s not like it always was before?

Not sure about “always”. I tested a few generations back, which displayed the same behavior.

Being a “late adopter”, I am not sure that it has ever worked to my (and ml9104’s) liking in LibreOffice Math, so whether it is a regression in the literal sense is a matter of definition, and of taste I guess. “What some users see as a feature, others see as a bug.”

“Regress” (meaning something like “reduce to previous, lesser or simpler state”), is perhaps an ill chosen term anyway. “Degenerate” may be better. Anyway, now I am splitting hairs…

Quoting @mikekaganski: "atan2/arctan2 is a well-known function distinct from atan"
Concerning "distinct from atan I agree. Otherwise: Obviously there are well-known things not so well-known to me. I cannot remember a case where I found one of these function names with the “2” at the end outside spreadsheets, and the current opendocument v1.3 part 4 tells “…ATAN2(0;0) is implementation-defined, evaluators may return 0 or an Error.”
If I needed a 2π value-range for an “extended arctan” I used the arg() function applied to a complex number, and I wouldn’t object if an “overloaded arg function” accepted arg(x, y) in place of arg(x + i y). Using the name atan2 would still suggest to me a function inverting the tan - and this isn’t clean.
And, of course: Math should recognize atan2 as a function name in the given case. Thanks to @keme.

@Lupp: well, the wikipedia article mentions other uses (not only spreadsheets). Given that ‘tan’ is a function named after ‘tangent line’ (and not the other way round), I would disagree with the claim that the function name is misleading or wrong. It gives an angle (arc) of a tangent line defined by two points: (0,0) and (x,y).

No need to insist.
Simply: If I was the one to choose a name for that function, I would have done otherwise. However, the word “Argumentwinkel” (argument- angle) I was somehow used to may be “traditional” at least in Germany, but is also bad for misusing a more general word in a specialized meaning without sufficient clarification. polarangleforcartesiancoordinates is good, but too long. In fact a clearly namable and efficient function should return the pair giving the polar coordinates for the pair of cartesian coordinates. polar(x, y) = (r, phi); cartesian(r, phi) = (x, y). But … (you know).
Well, there are so many idiotic words and constructs in any spoken language or Newspaperish that we may pardon “Mathematish” for its occasional squirts of mud.

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:

1 Like

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

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.

1 Like

OK, solved somehow.
Anyhow, it’s all about layout, readability and aesthetics of formulas.
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.

1 Like