specialTrigValues.pl

Subroutines for converting numbers that arise in a trigonometry setting into "nice" expressions like pi/4 and sqrt(3)/2

Description

specialRadical(x) returns a MathObject Formula in Complex context of the form "a sqrt(b)/c" that is the closest possible to x, where a is an integer, and b and c are from specified sets of positive integers. By default, both b and c come from [1,2,3]. If c is 1, it will be omitted from the expression. If b is 1, the "sqrt(1)" will be omitted. If a is 1, it will be omitted unless the whole thing is 1. If a is -1, the "1" will be omitted unless the whole thing is -1. If x is non-real, this process is applied to the Real and Imaginary parts separately.

specialAngle(x) returns a MathObject Formula in Numeric context of the form "a pi/c" that is the closest possible to x, where a is an integer, and c is from a specified set of positive integers. By default, c comes from [1,2,3,4,6].

Options

Both specialRadical(x) and specialAngle(x) can take an optional argument denominators => [list of positive integers]. These will be the denominators under consideration for finding a closest expression.

specialRadical(x) can take an optional argument radicands => [list of positive integers]. These will be the radicands under consideration for finding a closest expression.