{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 3: Vectors" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 3.1: Sample_Problem_1.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec('degree_rad.sci', -1)\n", "\n", "//Given that\n", "a = [2,0]\n", "b = [2 *cos(dtor(30)),2 *sin(dtor(30))]\n", "c = [-1,0]\n", "\n", "//Sample Problem 3-1\n", "printf('**Sample Problem 3-1**\n')\n", "poss = [norm(a+b+c) norm(a-b+c), norm(a+b-c), norm(a-b-c)]\n", "max_norm = 0\n", "for v = poss\n", " if v > max_norm then max_norm = v \n", " end\n", "end\n", "printf('The maximum possible value is %f m', max_norm)" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 3.2: Sample_Problem_2.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec('degree_rad.sci', -1)\n", "\n", "//Given that\n", "dis = 215 //in km\n", "position = [dis * cos(dtor(22)), dis * sin(dtor(22))]\n", "\n", "//Sample Problem 3-2\n", "printf('**Sample Problem 3-2**\n')\n", "printf('The plane is %f km in the north & %f in the east', position(1),position(2))" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 3.3: Sample_Problem_3.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec('degree_rad.sci',-1)\n", "\n", "//Given that\n", "displacement_vector = [-2.6,-3.9,.025] //each in km\n", "\n", "//Sample Problem 3-3\n", "printf('**Sample Problem 3-3**\n')\n", "mag = norm(displacement_vector)\n", "sw_angle = atan(displacement_vector(2)/displacement_vector(1))\n", "up_angle = displacement_vector(3)/norm(displacement_vector)\n", "printf('The team displacement vector had a magnitude %f km,\n and was at an angle of %d south of west and\n at an angle of %f upward', mag, rtod(sw_angle), rtod(up_angle))" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 3.4: Sample_Problem_4.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec('degree_rad.sci',-1)\n", "\n", "//Given that\n", "a = [4.2,-1.5]\n", "b = [-1.6,2.9]\n", "c = [0,-3.7]\n", "\n", "//Sample Problem 3-4\n", "printf('**Sample Problem 3-4**\n')\n", "r = a + b + c\n", "magnitude = norm(r)\n", "angle = rtod(atan(r(2)/r(1)))\n", "printf('The magnitude of the vector is %f m & the angle measured from the x axis is %f', magnitude, (angle) )" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 3.5: Sample_Problem_5.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec('degree_rad.sci',-1)\n", "\n", "//Given that\n", "a = [36,0] //in km\n", "c = [25 *cos(dtor(135)), 25 *sin(dtor(135))] //in km\n", "d_mag = 62 //in km\n", "\n", "//Sample Problem 3-5\n", "printf('**Sample Problem 3-5**\n')\n", "//we have a + b + c = d\n", "//therefore ax = bx + cx + dx\n", "// bx = 0\n", "d_x = a(1) + c(1)\n", "d_y = d_mag * sqrt(1 - (d_x/d_mag)^2)\n", "d = [d_x, d_y]\n", "b = d(2) - a(2) - c(2)\n", "printf('The magnitude of b is equal to %f km', b)" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 3.6: Sample_Problem_6.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec('degree_rad.sci',-1)\n", "\n", "//Given that\n", "a = [3,-4,0]\n", "b = [-2,0,3]\n", "\n", "//Sample Problem 3-6\n", "printf('**Sample Problem 3-6**\n')\n", "angle_ab = acos(-norm(a*b')/(norm(a) * norm(b)))\n", "printf('The angle between given vectors is %f degress', rtod(angle_ab))" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 3.7: Sample_Problem_7.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec('degree_rad.sci',-1)\n", "exec('cross_product.sci',-1)\n", "\n", "//Given that\n", "a = [18 * cos(dtor(250)), 18 * sin(dtor(250)),0]\n", "b = [0,0,12]\n", "\n", "//Sample Problem 3-7\n", "printf('**Sample Problem 3-7**\n')\n", "cross_ab = crossproduct(a,b)\n", "angle_x = acos(cross_ab(1)/norm(cross_ab))\n", "printf('The magnitude of cross product of given vectors is %f \n and angle with the x axis in degrees is %f', norm(cross_ab),rtod(angle_x))" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 3.8: Sample_Problem_8.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec('degree_rad.sci',-1)\n", "exec('cross_product.sci',-1)\n", "\n", "//Given that\n", "a = [3,-4,0]\n", "b = [-2,0,3]\n", "\n", "//Sample Problem 3-8\n", "printf('**Sample Problem 3-8**\n')\n", "cross_ab = crossproduct(a,b)\n", "printf('The cross product of given vectors is ')\n", "disp(cross_ab)" ] } ], "metadata": { "kernelspec": { "display_name": "Scilab", "language": "scilab", "name": "scilab" }, "language_info": { "file_extension": ".sce", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/x-octave", "name": "scilab", "version": "0.7.1" } }, "nbformat": 4, "nbformat_minor": 0 }