M
M
mlsedov2015-04-23 21:27:33
JavaScript
mlsedov, 2015-04-23 21:27:33

How to handle the break point in Math.atan(1/x)?

Implemented the construction of graphs of functions of the form y=... on canvas.
I can not solve one problem, identifying the asymptote of the function y=atan(1/x).
At point zero produces a numeric value, i.e. in javascript, Math.atan(1/0) produces the value 1.5707963267948966 while Math.tan(1/0) produces NaN which can be processed.
How is it possible to bypass this feature of javascript?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Shatokhin, 2015-04-23
@mlsedov

function atan (num) {
  if (num === Infinity || num === -Infinity)
    return NaN;
  return Math.atan(num);
}

atan(1/0); // NaN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question