Introduction
In this article, I am describing some of the TypeScript math functions.
In TypeScript the asin() method returns a numeric value between -pi/2 and pi/2 radians for x between -1 and 1. If the value of a number is outside this range then it returns NaN.
Syntax
Asin() function
- asin (number)
function
- Asin(num: number) {
- var span = document.createElement("span");
- span.innerText = "The arcsine of " + num + " is -> " + Math.asin(num) + "\n";
- document.body.appendChild(span);
- }
Acos() function
- acos (number)
function
- Acos(num: number) {
- var span = document.createElement("span");
- span.innerText = "The arccosine of " + num + " is -> " + Math.acos(num) + "\n";
- document.body.appendChild(span);
- }
Atan() function
Syntax
- acos(number)
function
- Atan(num: number) {
- var span = document.createElement("span");
- span.innerText = "The arctangent of " + num + " is -> " + Math.atan(num);
- document.body.appendChild(span);
- }
Complete Program
Function.ts
- class Greeter {
- Asin(num: number) {
- var span = document.createElement("span");
- span.innerText = "The arcsine of " + num + " is -> " + Math.asin(num) + "\n";
- document.body.appendChild(span);
- }
- Acos(num: number) {
- var span = document.createElement("span");
- span.innerText = "The arccosine of " + num + " is -> " + Math.acos(num) + "\n";
- document.body.appendChild(span);
- }
- Atan(num: number) {
- var span = document.createElement("span");
- span.innerText = "The arctangent of " + num + " is -> " + Math.atan(num);
- document.body.appendChild(span);
- }
- }
- window.onload = () => {
- var obj = new Greeter();
- var num = parseFloat(prompt("Enter a number for calculate Asin,Acos and Atan"));
- obj.Asin(num);
- obj.Acos(num);
- obj.Atan(num);
- };
default.htm
- <!DOCTYPE html>
- <html lang="en"
- xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta charset="utf-8" />
- <title>TypeScript HTML App</title>
- <link rel="stylesheet" href="app.css" type="text/css" />
- <script src="app.js"></script>
- </head>
- <body>
- <h2>Asin,Acos and Atan Math Function in TypeScript</h2>
- <div id="content"/>
- </body>
- </html>
app.js
- var Greeter = (function() {
- function Greeter() {}
- Greeter.prototype.Asin = function(num) {
- var span = document.createElement("span");
- span.innerText = "The arcsine of " + num + " is -> " + Math.asin(num) + "\n";
- document.body.appendChild(span);
- };
- Greeter.prototype.Acos = function(num) {
- var span = document.createElement("span");
- span.innerText = "The arccosine of " + num + " is -> " + Math.acos(num) + "\n";
- document.body.appendChild(span);
- };
- Greeter.prototype.Atan = function(num) {
- var span = document.createElement("span");
- span.innerText = "The arctangent of " + num + " is -> " + Math.atan(num);
- document.body.appendChild(span);
- };
- return Greeter;
- })();
- window.onload = function() {
- var obj = new Greeter();
- var num = parseFloat(prompt("Enter a number for calculate Asin,Acos and Atan"));
- obj.Asin(num);
- obj.Acos(num);
- obj.Atan(num);
- };
Output 1

Output 2


Comments
Join the conversation! Your thoughts help the community grow.