1

Reasonable imprecision is OK, but diverging from a calculator by entire 10 degrees is unacceptable.

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{math}
\tikzmath
  { \angle=sin(9.00000/9.48683)^-1;
  } % should be 71.56445
\begin{document}
  \angle % 60.38649
\end{document}
2
9

Calculators often denote the arc sin function as sin-1 (probably because it's more compact to write on the button) because arc sin is the inverse of sin (that is, one computes an angle given the sine, the other computes the sine given an angle).

However arc sin(x) is not equal to sin(x)-1. It's easy to see that if you take a more extreme angle. arc sin(0) is zero (note that WolframAlpha transcribes the input arcsin(0) to sin-1(0), which should not be confused with sin(0)-1), however sin(0)-1 gives a slightly larger result ;-)

sin-1(x) denotes the inverse sine of x, where the superscript -1 is not an exponent. Whereas sin(x)-1 is the reciprocal of sin(x), in which case the -1 is an exponent, which means 1/sin(x) (see this thread and Crowley's comment below this answer). However very few systems understand the sin-1(x) notation (probably Wolfram and one or two more), because it's tricky to teach a parser that a ^-1 after sin means a completely different thing than a ^2 in the very same place. Add that to the usual difficulty of programming anything in TeX and you see why this doesn't work.

If you use the proper notation, pgfmath computes both correctly:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{math}
\tikzmath { \anglea=sin(9.00000/9.48683)^-1; }
\tikzmath { \angleb=asin(9.00000/9.48683); }
\begin{document}
  \anglea % 60.38649
  \space
  \angleb % 71.56462
\end{document}

so does xfp ;-)

\documentclass[border=5mm]{standalone}
\usepackage{xfp}
\begin{document}
  \fpeval{sind(9.00000/9.48683)^-1} % 60.39779524788624
  \space
  \fpeval{asind(9.00000/9.48683)} % 71.56510517950239
\end{document}
4
  • 4
    For the LaTeX3 FPU, I'd use sind and asind as the conversion between degrees and radians is tricky – Joseph Wright Nov 14 '19 at 23:31
  • 1
    I wish I can add +1/0 for the "slightly larger result" note. You owe me cleaning the screen for that. – Crowley Nov 15 '19 at 13:07
  • 1
    I"d add the source of the confusion. The inverse functions are often denoted with -1 index. f^-1(f(x)) = x. With this notation, the arcus sinus may be denoted as sin^-1(x). On the other hand, the denominators are also written as nominators powered by -1. Therefore 1/sin(x) is transcripted as sin(x)^-1 which is, to be more precise (sin(x))^-1. – Crowley Nov 15 '19 at 13:14
  • @Crowley Thanks for the explanation. I added a paragraph to the answer – Phelype Oleinik Nov 15 '19 at 13:20

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.