Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

#1 2008-01-04 02:23:48

luca-deltodesco
Super Member
Award: Wink Alive

Offline

interesting little problem

a friend posted me the following problem:

inverse tangent is multi-valued and restricts its result to the range -π to π. how can i get back to the original number if it wasn't in this range? obvously thats impossible since from the result you can have no idea, but he added the restriction of it being a positive integer, and thus becomes feasable

my answer was: (inp is the result of the inverse tangent)

while ((inp += pi)-int(inp)>1e-8);

which works up to the limit of numerical accuracy (only works up to about 200 before failing due to numerical innacuracies)

so as an example.

set inp to atan(tan(125)); run the loop, and you get inp=125.000000016

not very difficult at all, but i still found it interesting

Last edited by luca-deltodesco (2008-01-04 02:24:29)


The Beginning Of All Things To End.
The End Of All Things To Come.

#2 2008-01-04 08:35:22

MathsIsFun
Administrator

Offline

Re: interesting little problem

Is it necessary to work out every "inp + n(pi)" until you find it?


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

#3 2008-01-04 20:38:01

luca-deltodesco
Super Member
Award: Wink Alive

Offline

Re: interesting little problem

well the problem is, how would you find out how many pi's you have to add to get to an integer?


The Beginning Of All Things To End.
The End Of All Things To Come.

#4 2008-01-04 22:58:49

mikau
Super Member

Offline

Re: interesting little problem

aye, but that seems like... i'm not sure.

could we possibly prove that it is the exact answer?

I guess we can't be sure unless we can find an expression for the tangent of some integer that fits on one piece of paper.


A logarithm is just a misspelled algorithm.

Board footer

Powered by FluxBB