Wolfram Research

Function Repository Resource:

TrigDataset

Source Notebook

Get trigonometric datasets including closed-form values

Contributed by: Claudio Lobo Chaib Filho

ResourceFunction["TrigDataset"][f]

gets a dataset for the specified trigonometric function f.

Details and Options

The function f can be any of the following: Sin, Cos or Tan (or "Sine", "Cosine" or "Tangent").
The angles in the generated table are in steps of 3 degrees by default, but it is possible to have closed-form values with different granularity.
ResourceFunction["TrigDataset"] supports the following options:
"Digits" 2 precision of the "Decimal" result
"DegreeStep" 3 step size (in degrees) between rows in the result
The "DegreeStep" option accepts Quantity, either as a degree or as radians. If not specified by Quantity, the default is degree.

Examples

Basic Examples

Generate a dataset for the Sin function:

In[1]:=
ResourceFunction["TrigDataset"][Sin]
Out[1]=

Scope

Generate some trigonometric data:

In[2]:=
sindata = ResourceFunction["TrigDataset"]["Sine"];

Show all information for a specified row:

In[3]:=
sindata[3]
Out[3]=

Select one of the columns in this row to show the result in standard closed form:

In[4]:=
sindata[3, "Radians"]
Out[4]=

Show the entire row outside of the dataset with StandardForm:

In[5]:=
sindata[3][StandardForm]
Out[5]=

Options

With the "Digits" option, one can get any precision value for the results in the "Decimal" column:

In[6]:=
ResourceFunction["TrigDataset"][Cos, "Digits" -> 20]
Out[6]=

Use the option "DegreeStep" to specify the difference between the angle at successive rows in the results. Values which are multiples of 1/8 will give results in terms of radicals:

In[7]:=
ResourceFunction["TrigDataset"]["Cosine", "DegreeStep" -> 2][5]
Out[7]=

Use 12-degree steps:

In[8]:=
ResourceFunction["TrigDataset"]["Sine", "DegreeStep" -> 12][StandardForm]
Out[8]=

Show multiple results simultaneously:

In[9]:=
tandata = ResourceFunction["TrigDataset"][Tan, "DegreeStep" -> Quantity[3/2, "Degree"]];
In[10]:=
tandata[[2 ;; 4]][StandardForm]
Out[10]=

For many "DegreeStep" values, one can obtain a radical result using "Value":

In[11]:=
tandata[1, "Value"]
Out[11]=

Use a Quantity for "DegreeStep"to specify radians:

In[12]:=
ResourceFunction["TrigDataset"][Cos, "DegreeStep" -> Quantity[Pi/15, "Radians"]]
Out[12]=
In[13]:=
ResourceFunction["TrigDataset"][Cos, "DegreeStep" -> Quantity[12, "Degree"]]
Out[13]=

Possible Issues

Sometimes the result of the closed form appears inside the dataset, which is not very useful for copying the result:

In[14]:=
sin6 = ResourceFunction["TrigDataset"][Sin, "DegreeStep" -> 1/2];
sin6[5, "Value"]
Out[15]=

Retrieve the StandardForm:

In[16]:=
sin6[5, "Value"][StandardForm]
Out[16]=

The smaller the "DegreeStep", the longer the time to evaluate. Tangent with step 1/2 takes about 10 minutes and step 3/8 takes about 20 minutes:

In[17]:=
ResourceFunction["TrigDataset"][Tan, "DegreeStep" -> 1/2]; // Timing
Out[17]=
In[18]:=
ResourceFunction["TrigDataset"][Tan, "DegreeStep" -> 3/8]; // Timing
Out[18]=

Resource History

Related Resources

License Information