Bug 144066 - Tangent function is returning a number to the order of 10^16 for PI/2
Summary: Tangent function is returning a number to the order of 10^16 for PI/2
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.1.5.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-24 17:40 UTC by John R Sohn
Modified: 2021-08-25 10:49 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John R Sohn 2021-08-24 17:40:38 UTC
Description:
the tangent function =tan(radians) is returning a value way out of range.

to reproduce set a cell to pi()/2 and then another to take the value =tan(cell)



Steps to Reproduce:
1. Create cell with value PI()/2 as the value, lets say in A1
2. Create another cell with tan function referencing it.  say in B2 the val =tan(A1)

Will also happen if you set tan equal to the value itself so =TAN(PI()/2)

Of note the value =TAN(PI()/4) returns 1 like it should.


Actual Results:
1.63312393531954E+016

Expected Results:
0.027422438


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
It should have calculated the correct tangent value...
Comment 1 Jean-Baptiste Faure 2021-08-25 08:25:36 UTC
Hmmm, tan() = sin()/cos()
sin(Pi/2) = 1
cos(Pi/2) = 0
then tan(Pi/2) = +infinity
so the value provided by Calc is a relatively correct approximation.

What is your source for your expected value?
https://en.wikipedia.org/wiki/Trigonometric_functions#Simple_algebraic_values

Closing as NotABug.

Best regards. JBF
Comment 2 [REDACTED] 2021-08-25 10:49:44 UTC
(In reply to John R Sohn from comment #0)
> Description:
> the tangent function =tan(radians) is returning a value way out of range.

> Expected Results:
> 0.027422438

Your expectation is based on TAN(A1*PI()/180), which is converting a value, which is already in radians (rad), once more into radians.