Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 557

Rename this file as Chapter_1_Assignment_TurnIn.sagews

  • To do this, go to the file menu (click Files above), then click

The following will be useful for writing up your answers.

Markdown Formating

Double-click on the text in this cell. Notice how the first line of the source text is actuall %md. This tells SageMath that everything inside this cell is Markdown language and not mathematics. Markdown is an abbreviated form of HTML that allows you to format text quickly.

Take a look at the source text below and notice how using the hashtags allows us to create large header text.

This is a header

This is a smaller header

They keep getting smaller and smaller as I add hashtags

In addition to creating headers, which help divide text into sections, you can also add horizontal lines by using three dashes (see below)


Bulleted lists can be created using single dashes

  • Notice that there is a space in the source text between the dash and the letter 'N' in 'Notice'

  • Without this space you get the following

-Here is no space

You can also create italisized text by placing asterisks on either side of a word like this.

Bold test is created by surrounding a word with double-asterisks like this

You can find a tutorial on markdown at Markdown Tutorial

SageMath is similar to Mathematica, Matlab, Maple, or other mathematical software programs. It simplifies numerical and algebraic operations. Each worksheet (this page is a worksheet) is broken into cells. The two types of cells are input cells and output cells. You type your calculations into into an input cell and then hit Shift+Enter to evaluate the cell. SageMath provides the answers to your calculations in an output cell. Click on the input cell below and hit Shift+Enter to evaluate the calculations.

Evaluate a cell

  • Place the cursor in the input cell and hit Shift+Enter to tell SageMath to evaluate a cell.

#This is an input cell #Any text that appears after a hashtag is a comment and is not processed by SageMath #Click in this cell and hit Shift+Enter to evaluate it 10+20+30 2*17*21 5^5 1/3 3/4 (2^7)/(3^2+1)
60 714 3125 1/3 3/4 64/5

Notice how 1/31/3, 3/43/4, and 64/564/5 are left as ratios and not converted to decimals. This is because SageMath leaves results in their exact form and does not convert the results to decimal-form unless you tell it to. To evaluate 1/31/3 and get the answer to three significant figures you would use the numerical approximation command n(1/3,digits=3).

Get a numerically approximate answer and specify the number of significant figures

  • Use n() to get an approximate answer

    • Place the equation to evaluate inside the parentheses

    • Include digits=5 to get a numerical result to five significant figures

      • Don't forget to put a comma between your equation and digits=5

#Try changing the number of significant figures for each of the calculations n(1/3,digits=1) n(3/4, digits=1) n(7/4,digits=2) n(pi,digits=4) n(e,digits=4)
0.33 0.75 1.8 3.142 2.718

Problem 1

(Problem 1-12 in Hibbeler)

Evaluate the following to three significant figures (don't worry about units yet - we'll get to those in a minute)

  1. 68443\frac{684}{43}

  2. 280.0458\frac{28}{0.0458}

  3. 2.68426\frac{2.68}{426}

#Insert your answers for problem 1 here: #Problem 1-1 answer below #Problem 1-2 answer below #Problem 1-3 answer below

Any letter you want to treat as a variable (you don't want to assign a numerical value to it) must be declared as a variable using the var() command. All variable names cannot contain spaces (although you can use underscores _ instead of a space), cannot start with numbers or special characters (anything not a letter) or contain special characters (although they can contain numbers).

The standard SI units are the following:

  • Length: meter (abbreviated as m)

  • Time: second (abbreviated as s)

  • Mass: kilogram (abbreviated as kg)

  • Force: Newton (abbreviated as N)

The customary U.S. units of measure are:

  • Length: foot (ft)

  • Time: second (s)

  • Mass: slug (slug)

  • Force: pound (lb)

To use these as units we will tell SageMath that they are variables using var(). An easy way to convert units is to define new units in terms of the original units. For instance, if your results are given in centimeters you could add the code cm=m/100. Then typing in an answer in cm it would be converted into m.

Defining variables

  • Place units in quotes inside the parentheses in var()

    • For example, to specify m and s as variables you would enter `var('m,s')

    • Many times you will see m,s=var('m,s'). This is not needed but can make it clearer that you are specifying letters as variables.

var('m,s,kg,N,ft,slug,lb') #To convert results in centimeters or nanometers into meters you could do the following: cm=m*10^(-2) nm=m*10^(-9) distance_1=13*cm distance_1 distance_2=55*nm distance_2 #The numerical approximation command n() cannot handle variables so you must divide out variables and then add them back in by hand #Divide distance_1 by m to get rid of the m symbol, then multiply the m back on n(distance_1/m,digits=2)*m #Divide distance_2 by m when using the n() command, then multiply the m back on to the answer n(distance_2/m,digits=3)*m
(m, s, kg, N, ft, slug, lb) 13/100*m 11/200000000*m 0.13*m (5.50e-8)*m

Problem 1A (Again but with units)

Evaluate the following to four significant figures and convert all answers to standard SI units

  1. 684μm43ms\frac{684 \mu m}{43 ms}

  2. 28ms0.0458Mm\frac{28 ms}{0.0458 Mm}

  3. 2.68mm426Mg\frac{2.68 mm}{426 Mg}

#Insert your work for problem 1A below #You can copy and paste your earlier work and then modify it #Problem 1A-1 answer below #Problem 1A-2 answer below #Problem 1A-3 answer below

Unit conversion can be accomplished using the .substitute() command. You can tell SageMath to substitute one variable in for another. For example, to convert from meters to feet, substitute in m=3.28084*ft and evaluate it.

Substitute one variable for another

  • The .substitute() command is added to the end of a variable

    • To replace ft with 0.3048*m in the variable called d, you would type d.substitute(ft=0.3048*m)

  • The arguments in the parentheses sets the orignal variable equal to the new value

  • You can specify several substitutions at once by separating substitutions with commas

    • To replace ft with 0.3048*m and ns with s*10^(-9) in the variable v you would type v.substitute(ft=0.3048*m, ns=s*10^(-9))

  • This isn't just for unit conversion, this works for any two variables in a function

    • To replace y with 3*x-5 in function f you would type f.substitute(y=3*x-5)

#Convert "dist" from meters to feet dist=71*m #Define variable "dist" dist.substitute(m=3.28084*ft) #Convert "dist" from meter to feet #One trick you can use to get the correct number of significant figures is to leave off the new unit, use n(), then add the new unit on to the end n(dist.substitute(m=3.28084),digits=2)*ft #Notice how the new units are OUTSIDE the n() command #Convert "vel" from miles/hour to meters/second var('mi,hr') #I want to use miles and hours so I need to define these as variables vel=17.0*mi/hr #Define the velocity variable called "vel" new_vel=vel.substitute(mi=1609*m,hr=60*60*s) #Notice that SageMath doesn't print out a result when you assign an evaluation to a variable... new_vel #... but by evaluating the new variable SageMath will print out the results #To get the correct number of sig. figs.: n(vel.substitute(mi=1609,hr=60*60),digits=2)*m/s
232.939640000000*ft 230.*ft (mi, hr) 7.59805555555556*m/s 7.6*m/s

Problem 2

(problem 1-16 in Hibbeler)

The pascal (Pa) is actually a very small unit of pressure. To show this, convert 1Pa=1N/m21 Pa = 1 N/m^2 to lb/ft2lb/ft^2.

Hint: Work in N and m, not Pa

  1. How much is 1Pa1 Pa in lb/ft2lb/ft^2?

  2. Atmospheric pressure at sea level is 14.7lb/in214.7 lb/in^2. How many pascal is this?

  3. How many pascal is 1lb/in21 lb/in^2?

#Insert your answer for problem 2 here #Be sure to include a description of what you are doing using comments and label each problem answer (e.g. #Problem 2-1 answer)

You can define functions in SageMath by giving the function a name and specifying the arguments of the function in parentheses after the function name. For example, to define a function f(x)f(x) you might type f(x)=3*x^2+2*x-1. You can also have functions of multiple variables such as h(x,y,z)=3*x*y-z^3

Defining Functions

  • Function names follow same convention as variables; Must start with a letter, can contain numbers, can't contain spaces (only underscores _), and no special characters

  • Format is function_name(variable1,variable2,)= equation such as g(a,b)=2*a+3*b

  • Functions can be evaluated at specific points by entering numbers in for the arguments such as g(1,2)

f(x)=3*x^2+7*x-17 #Defining a function f of x #Try evaluating this function at the following points: x=0, x=5, x=7 #For example, type f(0) to evaluate at x=0

The gravitational force is defined in section 1.2 in Hibbeler. Newton's law of gravitational attraction is given by

F=Gm1m2r2F=G \frac{m_1 m_2}{r^2}

where the universal gravitational constant G=6.673×1013Nm2kg2G=6.673 \times 10^{-13} \frac{N m^2}{kg^2} and rr is the center-to-center distance between the two objects. It is important to remember that rr is measured from the center of mass of one object to the center of mass of the other. To find the force between the Earth and a person you would measure the distance from the center of the Earth (it's radius) to the center of the person (roughly below the sternum in most people).

You can find more information on Newton's law of gravitation here

Problem 3

The mass of the Earth is mE=5.972×1024kgm_E = 5.972\times10^{24} kg and the average radius of the Earth is RE6.371×106mR_E \approx 6.371\times10^6 m.

  1. Define a function Fgrav(m1,m2,r)F_{grav}(m_1,m_2,r) that calculates the gravitational force between two objects of masses m_1, m_2, that are a distance r apart.

  2. Calculate the gravitational force on a 1 kg1\ kg object on the surface of the Earth.

  3. Calculate the gravitational force on the same object if it is 100 m100\ m above the Earth's surface (i.e. center-to-center distance is the Earth's radius plus 100 m)

  4. Calculate the gravitational force on the same object if it is 1000 m1000\ m above the Earth's surface.

  5. Describe how the gravitational force on the 1 kg1\ kg object changed going from ground-level to 100 m100\ m to 1000 m1000\ m.

  6. Explain why your previous answer is or is not surprising.

#Answer problem 3 here #Describe what you are doing and be sure to label each sub-problem (e.g. #Problem 3-1 answer)

Problem 4

The quantity GmEr2G \frac{m_E}{r^2} doesn't change much near the Earth's surface so we created a variable to represent the near-Earth gravitational field and called it little g where g9.81ms2g \approx 9.81 \frac{m}{s^2} or, in silly units g32fts2g \approx 32 \frac{ft}{s^2}. Note, this is not the acceleration due to gravity (even though the book makes this claim). Call it the 'near-Earth gravitational field constant' or simply 'little g'. Do not call it 'gravity' or I will make a very pained expression and glare at you 😉. The only time an object accelerates at 9.81m/s29.81 m/s^2 is when the object is in free fall, near the surface of the Earth, in a vacuum.

  1. Create a function W(m)W(m) that calculates the gravitational force on an object by the Earth near the Earth's surface (i.e. the 'weight' of an object).

  2. Calculate the weight of a person with a mass of 83.0 kg83.0\ kg, including units and the correct number of significant figures.

  3. Calculate the weight of a car with a mass of 1200 kg1200\ kg, including units and the correct number of significant figures.

#Answer problem 4 here #Describe what you are doing in detail and be sure to label each sub-problem (e.g #Problem 4-1 answer)

Problem 5

Laws of Sines and Cosines

Use either the law of sines and the law of cosines to determine the unknown side lengths in the following problems. Calculate the sides as many different ways as you can and make sure that all results are the same. You can check that each answer is reasonable by comparing the results.

  1. Find the magnitude of Fu\vec{F}_u and the magnitude of Fv\vec{F}_v for the figure below.

  1. Find the magnitude of FR\vec{F}_R and the magnitude of F\vec{F} for the figure below.

#Answer problem 5 here #Describe what you are doing in detail and be sure to label each sub-problem (e.g #Problem 5-1 answer)

Is your answer to problem 5-1 and 5-2 reasonable?

Double-click on this cell and explain why your answers to each part of problem 5 are reasonable or not. Since you calculated each answer multiple times you can check whether your result is reasonable by making sure all values are identical. Describe this here.

Problem 6

Summary of this assignment:

Write up a short summary of the topics covered and what you learned in this assignment. Imagine a friend in the class couldn't remember how he or she did the assignment and wanted you to help him or her remember everything that was covered - write up your summary to help this friend.

In case you haven't guessed already, you are the 'friend' and this is meant to (1) help you reflect on what you learned (called metacognition or thinking about how you think) and (2) to give you a study guide to help you get ready for exams and quizzes.