{"id":192325,"date":"2025-02-17T13:31:40","date_gmt":"2025-02-17T13:31:40","guid":{"rendered":"https:\/\/learnexams.com\/blog\/?p=192325"},"modified":"2025-02-17T13:31:42","modified_gmt":"2025-02-17T13:31:42","slug":"suppose-deg-is-an-angle-in-degrees","status":"publish","type":"post","link":"https:\/\/www.learnexams.com\/blog\/2025\/02\/17\/suppose-deg-is-an-angle-in-degrees\/","title":{"rendered":"Suppose deg is an angle in degrees"},"content":{"rendered":"\n<p>Q1. Suppose deg is an angle in degrees.\u00c3\u201a\u00c2 Write down the NumPy code that computes the counterclockwise rotation matrix.\u00c3\u201a\u00c2 Don&#8217;t forget to convert the angles into radians when necessary.<\/p>\n\n\n\n<p>\u00c3\u201a\u00c2<\/p>\n\n\n\n<p>def rotate(deg):<\/p>\n\n\n\n<p>\u00c3\u201a\u00c2<\/p>\n\n\n\n<p>Q2. Let\u00c3\u201a\u00c2 x\u00c3\u201a\u00c2 be a vector.\u00c3\u201a\u00c2 How do you use rotate(deg) to find a vector\u00c3\u201a\u00c2 y\u00c3\u201a\u00c2 that is normal to x?\u00c3\u201a\u00c2 Namely x,y&gt; = 0.<\/p>\n\n\n\n<p>\u00c3\u201a\u00c2<\/p>\n\n\n\n<p>y = \u2026<\/p>\n\n\n\n<p>\u00c3\u201a\u00c2<\/p>\n\n\n\n<p>Q3. Let\u00c3\u201a\u00c2 x\u00c3\u201a\u00c2 be a vector.\u00c3\u201a\u00c2 How do you find a vector\u00c3\u201a\u00c2 v\u00c3\u201a\u00c2 in the same direction as x but with |v| = 1.<\/p>\n\n\n\n<p>\u00c3\u201a\u00c2<\/p>\n\n\n\n<p>v = \u2026<\/p>\n\n\n\n<p>\u00c3\u201a\u00c2<\/p>\n\n\n\n<p>Q4. A hyperplane in 2D is the same as a line.\u00c3\u201a\u00c2 A hyperplane is defined by a normal vector\u00c3\u201a\u00c2 w\u00c3\u201a\u00c2 and a bias scalar b.\u00c3\u201a\u00c2 Write down the expression that defines points on the line that is the hyperplane in 2D defined by (w,\u00c3\u201a\u00c2 b).<\/p>\n\n\n\n<p>\u00c3\u201a\u00c2<\/p>\n\n\n\n<p>{\u00c3\u201a\u00c2 x :\u00c3\u201a\u00c2 \u2026 }<\/p>\n\n\n\n<p>\u00c3\u201a\u00c2<\/p>\n\n\n\n<p>Q5. Given a vector\u00c3\u201a\u00c2 x, and a hyperplane P defined by (w, b).\u00c3\u201a\u00c2 Describe how to compute the point\u00c3\u201a\u00c2 v\u00c3\u201a\u00c2 that is the projection of\u00c3\u201a\u00c2 x\u00c3\u201a\u00c2 on to the plane P.<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-6-color\"><strong>The Correct Answer and Explanation is :<\/strong><\/mark><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q1. Code for counterclockwise rotation matrix<\/h3>\n\n\n\n<p>To compute the counterclockwise rotation matrix, we use the following NumPy code. Remember that the angle must be converted into radians since NumPy trigonometric functions use radians.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\n\ndef rotate(deg):\n    rad = np.deg2rad(deg)  # Convert degree to radians\n    rotation_matrix = np.array(&#91;&#91;np.cos(rad), -np.sin(rad)],\n                                &#91;np.sin(rad), np.cos(rad)]])\n    return rotation_matrix<\/code><\/pre>\n\n\n\n<p>This function takes an angle in degrees and returns the corresponding 2D counterclockwise rotation matrix.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q2. Finding a vector ( y ) normal to vector ( x )<\/h3>\n\n\n\n<p>To find a vector ( y ) that is normal to ( x ), we can rotate ( x ) by 90 degrees counterclockwise. In 2D, rotating a vector by 90 degrees counterclockwise swaps the components and changes the sign of the new x-component.<\/p>\n\n\n\n<p>If ( x = [x_1, x_2] ), then ( y ) will be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>x = np.array(&#91;x1, x2])\ny = rotate(90).dot(x)  # Apply a 90 degree rotation to x<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Q3. Finding a unit vector in the same direction as ( x )<\/h3>\n\n\n\n<p>To find a unit vector ( v ) in the same direction as ( x ), you need to normalize ( x ) by dividing it by its magnitude (norm):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>x = np.array(&#91;x1, x2])\nv = x \/ np.linalg.norm(x)  # Normalize x to get a unit vector<\/code><\/pre>\n\n\n\n<p>This code will return a vector ( v ) of magnitude 1 that points in the same direction as ( x ).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q4. Expression for points on the hyperplane in 2D<\/h3>\n\n\n\n<p>In 2D, a hyperplane is simply a line, and its equation can be represented by the normal vector ( w ) and the bias ( b ). The points on this line are given by:<\/p>\n\n\n\n<p>[<br>{ x : w \\cdot x + b = 0 }<br>]<\/p>\n\n\n\n<p>Here, ( w \\cdot x ) is the dot product of ( w ) and ( x ), and the equation represents all points ( x ) on the line (hyperplane).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q5. Projection of vector ( x ) onto hyperplane ( P )<\/h3>\n\n\n\n<p>The projection of a vector ( x ) onto a hyperplane ( P ) defined by the normal vector ( w ) and the bias ( b ) can be found using the following steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>First, compute the dot product of ( x ) and ( w ).<\/li>\n\n\n\n<li>Compute the dot product of ( w ) with itself.<\/li>\n\n\n\n<li>Use these results to calculate the scalar projection of ( x ) onto ( w ).<\/li>\n\n\n\n<li>Subtract this projection from ( x ) to get the point ( v ) on the plane.<\/li>\n<\/ol>\n\n\n\n<p>The formula for the projection ( v ) is:<\/p>\n\n\n\n<p>[<br>v = x &#8211; \\frac{x \\cdot w + b}{w \\cdot w} w<br>]<\/p>\n\n\n\n<p>This formula computes the projection of ( x ) onto the hyperplane defined by ( w ) and ( b ).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation<\/h3>\n\n\n\n<p>To explain the process of computing the projection in more detail, we consider that the projection of ( x ) onto the hyperplane defined by the normal vector ( w ) is the closest point on the hyperplane to ( x ). The term ( \\frac{x \\cdot w + b}{w \\cdot w} w ) gives the vector that points from ( x ) to the hyperplane, and subtracting this from ( x ) yields the point ( v ) on the hyperplane.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Illustration<\/h4>\n\n\n\n<p>I\u2019ll generate a diagram showing the vector ( x ), the hyperplane ( P ), and the projection ( v ). Let me create that image for you.<\/p>\n\n\n\n<p>You&#8217;ve hit your daily maximum number of images. To ensure the best experience for everyone, we have rate limits in place. Please wait for the next day before generating more images. Your daily maximum will reset in 10 hours and 29 minutes.<\/p>\n\n\n\n<p>Let me know if you&#8217;d like further explanations or assistance with any of the questions!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q1. Suppose deg is an angle in degrees.\u00c3\u201a\u00c2 Write down the NumPy code that computes the counterclockwise rotation matrix.\u00c3\u201a\u00c2 Don&#8217;t forget to convert the angles into radians when necessary. \u00c3\u201a\u00c2 def rotate(deg): \u00c3\u201a\u00c2 Q2. Let\u00c3\u201a\u00c2 x\u00c3\u201a\u00c2 be a vector.\u00c3\u201a\u00c2 How do you use rotate(deg) to find a vector\u00c3\u201a\u00c2 y\u00c3\u201a\u00c2 that is normal to x?\u00c3\u201a\u00c2 Namely [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25],"tags":[],"class_list":["post-192325","post","type-post","status-publish","format-standard","hentry","category-exams-certification"],"_links":{"self":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/192325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/comments?post=192325"}],"version-history":[{"count":0,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/192325\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/media?parent=192325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/categories?post=192325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/tags?post=192325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}