{"id":35961,"date":"2022-10-30T17:55:28","date_gmt":"2022-10-30T17:55:28","guid":{"rendered":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/?p=35961"},"modified":"2026-09-29T17:31:03","modified_gmt":"2026-09-29T17:31:03","slug":"numpy-arcsin","status":"publish","type":"post","link":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/python-modules\/numpy\/numpy-arcsin","title":{"rendered":"NumPy Arcsin- A Complete Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello Readers! Welcome to the Fourth Tutorial of the series <a href=\"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/python\/numpy-trigonometric-functions\" data-type=\"post\" data-id=\"14347\">NumPy Trigonometric Functions<\/a>. From this tutorial, we will start with Inverse Trigonometric Functions provided by the NumPy Library.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we will understand the <strong>NumPy arcsin<\/strong> function and practice a lot of examples. We will also plot the arcsin() function using <strong>Matplotlib Library<\/strong>. Let&#8217;s get started.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>Also read: <a href=\"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/python-modules\/numpy\/numpy-cos\" data-type=\"post\" data-id=\"35570\">NumPy Cos \u2013 A Complete Guide<\/a><\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Arcsin Function &#8211; Quick Overview<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>There is an interesting fact to know about these Inverse Trigonometric Functions the output of these functions is an <strong>angle<\/strong> and the input is a <strong>number<\/strong>.<\/li><li><strong>arcsin<\/strong> is the representation of the inverse of the sine function.  <\/li><li>The <strong>arcsin<\/strong> function takes input in the range <strong>[-1,1]<\/strong> and produces the output between <strong>[-pi\/2, pi\/2]<\/strong>.  <\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What is NumPy arcsin?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">NumPy arcsin is one of the trigonometric functions provided by the NumPy Library. <strong>Real numbers<\/strong> and <strong>Complex Numbers<\/strong> can be passed as input to the NumPy arcsin function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">NumPy arcsin can be accessed as <code><strong>numpy.arcsin<\/strong><\/code><strong><code>(input)<\/code><\/strong>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax of NumPy arcsin<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:<\/strong> <code><strong>numpy.arcsin(input)<\/strong><\/code> where input can be a single number or a NumPy array of numbers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NumPy arcsin of Single Number <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s try some examples of the NumPy arcsin function to help us understand it better.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; gutter: true; title: ; notranslate\" title=\"\">\nimport numpy as np\n\nimport math\n\nprint(&quot;Printing the Sine inverse values in radians\\n&quot;)\n\nprint(&quot;Sin inverse of 0 is :&quot;,np.arcsin(0))\n\nprint(&quot;Sin inverse of 0.5 is :&quot;,np.arcsin(0.5))\n\nprint(&quot;Sin inverse of 1\/sqrt(2) is :&quot;,np.arcsin(1\/math.sqrt(2)))\n\nprint(&quot;Sin inverse of 1 is :&quot;,np.arcsin(1))\n\nprint(&quot;Sin inverse of -1 is :&quot;,np.arcsin(-1))\n\nprint(&quot;\\n&quot;)\n\nprint(&quot;Sine inverse values in degrees\\n&quot;)\n\nprint(&quot;Sin inverse of 1\/sqrt(2) is :&quot;,np.degrees(np.arcsin(1\/math.sqrt(2))))\n\nprint(&quot;Sin inverse of -1 is :&quot;,np.degrees(np.arcsin(-1)))\n\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nPrinting the Sine inverse values in radians\n\nSin inverse of 0 is : 0.0\nSin inverse of 0.5 is : 0.5235987755982989\nSin inverse of 1\/sqrt(2) is : 0.7853981633974482\nSin inverse of 1 is : 1.5707963267948966\nSin inverse of -1 is : -1.5707963267948966\n\n\nSine inverse values in degrees\n\nSin inverse of 1\/sqrt(2) is : 44.99999999999999\nSin inverse of -1 is : -90.0\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s take an example of the sine inverse of 1\/sqrt(2) which is equal to 45 degrees. Since the sine of 45 degrees is 1\/sqrt(2) so the sine inverse of 1\/sqrt(2) is 45 degrees. This is an interesting way to understand how the inverse trigonometric functions compute the result.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The above code snippet is pretty much clear where a number in the range [-1,1] is passed as an argument to the <code><strong>arcsin<\/strong><\/code> function and the output is an angle in radians.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> I have used <code><strong>np.degrees()<\/strong><\/code> a function to convert the output angle to degrees.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The output of the arcsin function in all the above cases lies in the range <strong>[-pi\/2,pi\/2]<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">NumPy arcsin of Complex Number<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">NumPy arcsin function takes a <strong>complex number<\/strong> as an argument.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; gutter: true; title: ; notranslate\" title=\"\">\nimport numpy as np\n\nprint(&quot;Sin inverse of 1+5j is: &quot;,np.arcsin(1+5j))\n\nprint(&quot;Sin inverse of 2+3j is: &quot;,np.arcsin(2+3j))\n\nprint(&quot;Sin inverse of 0.5+0.5j is: &quot;,np.arcsin(0.5+0.5j))\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nSin inverse of 1+5j is:  (0.1937931365549322+2.3309746530493123j)\nSin inverse of 2+3j is:  (0.5706527843210994+1.9833870299165355j)\nSin inverse of 0.5+0.5j is:  (0.45227844715119064+0.5306375309525179j)\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">The output is also a complex number.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> We cannot use the np.degrees() function with numpy.arcsin() when the input to the arcsin function is a complex number.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">NumPy arcsin of Invalid Number<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If a number that is not in the domain of the arcsin function is passed as an argument to the function, then the output is <strong>nan<\/strong>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; gutter: true; title: ; notranslate\" title=\"\">\nimport numpy as np\n\nprint(&quot;Sin inverse of 5 is :&quot;,np.arcsin(5))\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nSin inverse of 5 is : nan\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Every number out of the range [-1,1] is considered an invalid input to the <code><strong>arcsin<\/strong><\/code> function. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NumPy arcsin on Multiple Numbers <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The NumPy arcsin function can also take a NumPy Array of numbers as an argument.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Combining NumPy Array with Arcsin<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; gutter: true; title: ; notranslate\" title=\"\">\nimport numpy as np\n\na = np.array((-1 , 0 , 0.5 , 0.3 , 1))\n\nprint(&quot;Sine Inverse Values in radians :\\n&quot;,np.arcsin(a))\n\nprint(&quot;Sine Inverse Values in degrees :\\n&quot;,np.degrees(np.arcsin(a)))\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nSine Inverse Values in radians :\n &#x5B;-1.57079633  0.          0.52359878  0.30469265  1.57079633]\nSine Inverse Values in degrees :\n &#x5B;-90.           0.          30.          17.45760312  90.        ]\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">NumPy Arcsin on an Evenly-Spaced NumPy Array <\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, we will create a NumPy Array of 20 evenly spaced values using <code><strong>numpy.linspace<\/strong><\/code>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; gutter: true; title: ; notranslate\" title=\"\">\nimport numpy as np\n\na = np.linspace(-1 , 1 , 20)\n\nprint(&quot;Sin Inverse Values in radians: &quot;,np.arcsin(a))\n\nprint(&quot;Sin Inverse Values in degrees: &quot;,np.degrees(np.arcsin(a)))\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nSin Inverse Values in radians:  &#x5B;-1.57079633 -1.1078416  -0.90995103 -0.75352062 -0.6174371  -0.49346939\n -0.37731003 -0.26629402 -0.15855828 -0.05265591  0.05265591  0.15855828\n  0.26629402  0.37731003  0.49346939  0.6174371   0.75352062  0.90995103\n  1.1078416   1.57079633]\nSin Inverse Values in degrees:  &#x5B;-90.         -63.47464798 -52.13635364 -43.17355111 -35.37654015\n -28.27371363 -21.61827242 -15.25752329  -9.08472029  -3.01696131\n   3.01696131   9.08472029  15.25752329  21.61827242  28.27371363\n  35.37654015  43.17355111  52.13635364  63.47464798  90.        ]\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Visualizing the Arcsin Function<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; gutter: true; title: ; notranslate\" title=\"\">\nimport numpy as np\n\n# Importing the Matplotlib Library\nimport matplotlib.pyplot as plt\n\n# Creating a NumPy Array of 30 evenly-spaced elements\na = np.linspace(-1,1,30)\n\n# Storing the computed arcsin values in a NumPy Array\nb = np.arcsin(a)\n\nplt.plot(a, b, color = &quot;blue&quot;, marker = &quot;o&quot; , ms = 5,mfc = &quot;r&quot;)\nplt.title(&quot;numpy.arcsin()&quot;)\nplt.xlabel(&quot;X&quot;)\nplt.ylabel(&quot;Y&quot;)\nplt.show()\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"480\" src=\"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-content\/uploads\/2022\/11\/Arcsin-Plot-1.png\" alt=\"Arcsin Plot \" class=\"wp-image-36586\" srcset=\"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-content\/uploads\/2022\/11\/Arcsin-Plot-1.png 640w, https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-content\/uploads\/2022\/11\/Arcsin-Plot-1-300x225.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><figcaption><strong>Arcsin Plot <\/strong><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the plot, the values on Y-axis(Vertical Axis) are the output of <code><strong>arcsin<\/strong><\/code> the function in radians.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code><strong>plt.plot()<\/strong><\/code>&nbsp;the function is used to plot the arcsin Function which takes six arguments.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The&nbsp;<strong>first<\/strong>&nbsp;argument is the&nbsp;<strong>NumPy Array of numbers<\/strong>&nbsp;(created in Line No 7), plotted on the X-axis(Horizontal Axis).<\/li><li>The&nbsp;<strong>second<\/strong>&nbsp;argument is the output of the <code><strong>arcsin<\/strong><\/code> function, plotted on the Y-axis(Vertical Axis).<\/li><li>The&nbsp;<strong>third<\/strong>&nbsp;argument is the color of the plot.<\/li><li>The&nbsp;<strong>fourth<\/strong>&nbsp;argument is the marker value which emphasizes each point with a specified marker. There are different types of markers that can be used to denote the points on the curve.<\/li><li>The <strong>fifth<\/strong> argument is the <strong>size<\/strong> of the points on the curve. (ms is marker size)<\/li><li>The <strong>sixth<\/strong> argument is the color of the marker. (mfc is marker FACE color)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we learned about a variety of inputs that numpy.arcsin() function takes. Do practice these codes along with going through the articles. In the next tutorial, we will be covering the <a href=\"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/python-modules\/numpy\/numpy-arccos\">NumPy Arccos function<\/a> in detail.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/fd.xuwubk.eu.org:443\/https\/numpy.org\/doc\/stable\/reference\/generated\/numpy.arcsin.html\" target=\"_blank\" rel=\"noreferrer noopener\">NumPy Documentation &#8211; NumPy Arcsin<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/fd.xuwubk.eu.org:443\/https\/matplotlib.org\/stable\/users\/getting_started\/\" target=\"_blank\" rel=\"noreferrer noopener\">Matplotlib &#8211; Get Started<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/fd.xuwubk.eu.org:443\/https\/matplotlib.org\/stable\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">Matplotlib Documentation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Readers! Welcome to the Fourth Tutorial of the series NumPy Trigonometric Functions. From this tutorial, we will start with Inverse Trigonometric Functions provided by the NumPy Library. In this tutorial, we will understand the NumPy arcsin function and practice a lot of examples. We will also plot the arcsin() function using Matplotlib Library. Let&#8217;s [&hellip;]<\/p>\n","protected":false},"author":48,"featured_media":69685,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[93],"tags":[],"class_list":["post-35961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-numpy"],"_links":{"self":[{"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/posts\/35961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/users\/48"}],"replies":[{"embeddable":true,"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/comments?post=35961"}],"version-history":[{"count":0,"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/posts\/35961\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/media\/69685"}],"wp:attachment":[{"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/media?parent=35961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/categories?post=35961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fd.xuwubk.eu.org:443\/https\/www.askpython.com\/wp-json\/wp\/v2\/tags?post=35961"}],"curies":[{"name":"wp","href":"https:\/\/fd.xuwubk.eu.org:443\/https\/api.w.org\/{rel}","templated":true}]}}