to bootstrap my experience with Mathematica I'm trying to use it to print a table of values where the columns are different trigonometric functions and the rows contain different the values of said trig functions at some fixed angles that are between $0$ and $\frac{\pi}{2}$ .
After studying the basics I came up with this lines of code
vec = Prepend[Table[Pi/i, {i, Reverse[Range[2, 11]]}], 0];
res = Map[#, vec] & /@ {Sin, Cos, Tan, Csc, Sec, Cot};
TextGrid [res, Frame -> All]
and the output is
$\begin{array}{ccccccccccc} 0 & \sin \left(\frac{\pi }{11}\right) & \frac{1}{4} \left(\sqrt{5}-1\right) & \sin \left(\frac{\pi }{9}\right) & \sin \left(\frac{\pi }{8}\right) & \sin \left(\frac{\pi }{7}\right) & \frac{1}{2} & \sqrt{\frac{5}{8}-\frac{\sqrt{5}}{8}} & \frac{1}{\sqrt{2}} & \frac{\sqrt{3}}{2} & 1 \\ 1 & \cos \left(\frac{\pi }{11}\right) & \sqrt{\frac{\sqrt{5}}{8}+\frac{5}{8}} & \cos \left(\frac{\pi }{9}\right) & \cos \left(\frac{\pi }{8}\right) & \cos \left(\frac{\pi }{7}\right) & \frac{\sqrt{3}}{2} & \frac{1}{4} \left(\sqrt{5}+1\right) & \frac{1}{\sqrt{2}} & \frac{1}{2} & 0 \\ 0 & \tan \left(\frac{\pi }{11}\right) & \sqrt{1-\frac{2}{\sqrt{5}}} & \tan \left(\frac{\pi }{9}\right) & \tan \left(\frac{\pi }{8}\right) & \tan \left(\frac{\pi }{7}\right) & \frac{1}{\sqrt{3}} & \sqrt{5-2 \sqrt{5}} & 1 & \sqrt{3} & \text{ComplexInfinity} \\ \text{ComplexInfinity} & \csc \left(\frac{\pi }{11}\right) & \sqrt{5}+1 & \csc \left(\frac{\pi }{9}\right) & \csc \left(\frac{\pi }{8}\right) & \csc \left(\frac{\pi }{7}\right) & 2 & \frac{1}{\sqrt{\frac{5}{8}-\frac{\sqrt{5}}{8}}} & \sqrt{2} & \frac{2}{\sqrt{3}} & 1 \\ 1 & \sec \left(\frac{\pi }{11}\right) & \frac{1}{\sqrt{\frac{\sqrt{5}}{8}+\frac{5}{8}}} & \sec \left(\frac{\pi }{9}\right) & \sec \left(\frac{\pi }{8}\right) & \sec \left(\frac{\pi }{7}\right) & \frac{2}{\sqrt{3}} & \sqrt{5}-1 & \sqrt{2} & 2 & \text{ComplexInfinity} \\ \text{ComplexInfinity} & \cot \left(\frac{\pi }{11}\right) & \sqrt{2 \sqrt{5}+5} & \cot \left(\frac{\pi }{9}\right) & \cot \left(\frac{\pi }{8}\right) & \cot \left(\frac{\pi }{7}\right) & \sqrt{3} & \sqrt{1+\frac{2}{\sqrt{5}}} & 1 & \frac{1}{\sqrt{3}} & 0 \\ \end{array}$
the problems with this output are :
- some cells are in what it looks like a rational / expected form and others have a "weird" unevaluated form like $sin(\frac{\pi}{11})$ ; what is the problem with the latter ?
- I haven't found a way to print legends for the rows and the columns ( angle values and function names )
Thanks
res
? Also that unevaluated form is simply the exact form for the expression. If it knows the exact ratio or whatever it'll return that, but otherwise Mathematica has a principle of remaining as exact and symbolic as possible. $\endgroup$N
. That's its purpose. First part, isn't bad either. We'll do a bit of prepending. I'll knock you up a quick solution and explanation. $\endgroup$