2

On page 3/7 of the fp package we see the definition of the inverse sine function as below:

\FParcsin#1#2 % #1 := arcsin(#2)

From high school we may remember: Arcsin(0.5)=pi/6= 0.524 around. I got 0 for Arcsin(0.5) using fp package. Which is strange to me:

\documentclass{article}

\usepackage{fp}

\begin{document}
\FPdiv\pidivsix \FPpi 6 
\FParcsin \arcsinhalf 0.5 \\
\FParcsin \arcsinone 1 
Arcsin$(1)=\arcsinone$.\\
Arcsin$(\frac{1}{2})=\arcsinhalf$.\\
 This is a wrong answer the correct value is $\pidivsix$.

\end{document}

enter image description here

7
  • I'm no TeX specialist, but it seems to me that here, \frac{1}{2} is not interpreted as a number, but as a string. A TeX specialist can explain this better than I can.
    – AndréC
    Aug 10, 2020 at 5:02
  • I used frac 1 2 as a text to type and did not deal with it as a number.
    – Aria
    Aug 10, 2020 at 5:12
  • 5
    Try \FParcsin \arcsinhalf{0.5}. Otherwise your input is \FParcsin \arcsinhalf{0} and you are typesetting .5
    – cgnieder
    Aug 10, 2020 at 5:16
  • 5
    Replace \FParcsin \arcsinhalf 0.5 \\ with \FParcsin \arcsinhalf {0.5}. Apparently fp grabs the numbers like normal arguments. If you omit the braces, you only get 0. You can already see that something fishy is going on on the input stage from the fact that the document typesets a spurious '.5'.
    – moewe
    Aug 10, 2020 at 5:18
  • 1
    @Aria Indeed, you are right.
    – AndréC
    Aug 10, 2020 at 5:23

1 Answer 1

3

TeX will interpret a string of digits (with optional sign and optional decimal point or comma) as a decimal number only if it has to, that is

when it is looking for an explicit dimension, in which case the string representing a decimal number must be followed by one of the allowed units.

It's quite unfortunate that the documentation of fp presents the syntax in the shown form, because it might suggest resemblance to other programming languages that are more forgiving when numbers are involved.

Since TeX is mainly a typesetting program, it doesn't scan numbers except when it has to, but this can only happen when primitive commands are used, not with defined macros such as \FParcsin.

The suggestion \FParcsin#1#2 means that #1 and #2 are standard arguments that therefore should be braced (unless they consist of a single token). So

\FParcsin{\arcsinhalf}{0.5}

is the correct syntax. This can be abbreviated into \FParcsin\arcsinhalf{0.5} because the first argument is a single token.

You could safely type \FParcsin\arcsinone1, but it's better to stick to a standard and type \FParcsin\arcsinone{1}, so the arguments are also visually clearer.

Similarly, you should stick to

\FPdiv\pidivsix{\FPpi}{6}

for the same reasons. The code \FPdiv\pidivsix \FPpi 6 works, but if you try to compute pi over 10,

\FPdiv\pidivten \FPpi 10

would definitely not work and should be

\FPdiv\pidivten {\FPpi} {10}

or

\FPdiv\pidivten{\FPpi}{10}

Spaces are ignored when looking for an argument, so you have some freedom to suit your preferences.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.