This is the only assignment that you must use EES for. As with all assignments c
ID: 2246432 • Letter: T
Question
This is the only assignment that you must use EES for. As with all assignments completed with EES, hand in a print out of your Equations Window. Solution Window, and Plot Window using the print command in EES. No credit will be given for screen captures or copying the EES file into word or another program. You should highlight or box your solutions (right click on the value in the solutions window) in the equation window so that they are easy to find. Solve the following equation with EES: gamma/alpha + beta + c(alpha)^7 = 10 for gamma = 1, beta = 2, and c = 0.5. Make a plot showing how the solution varies as the value of c changes from 0.1 to 10. Note that you may need to add more points to your table to smooth your plot (at least 30 points usually is professional). If you arc still having trouble, try switching from linear to log number generation for the value of c. Cubic spline smoothing may also help.Explanation / Answer
In programming languages, storing some kind of data into the memory of the computer (in fact into the current symbolic workspace dened by your R session) is called assigning a value to a variable. When you assign a value (whatever its type: it can be a string of characters, an integer, a boolean variable, a oating-point number, etc) to a variable, you create a new object with R. This is done through the assignment operator ->. This operator is written with a hyphen (-) followed by a greater than sign (>), so that it forms an arrow. Taking care of swapping the two operands (variable and value), this can be also written the other way around: > 5 -> a # puts the value 5 into the variable a > b <- 7 # puts the value 7 into the variable b > b - a # asks for the evaluation (calculation) of b-a [1] 2 > 2 # nothing prevents you from evaluating a constant! [1] 2 The greater than character at the beginning of a commandline is the invite. It means that R is waiting for you to enter a command. Some commands produce a silent output (e.g. assigning a value to a variable is a silent operation), some other display a result. For example, subtracting the content of the variable called a from the content of the variable called b gives the single value 2 as an output. Notice that the [1] automatically prepended to the output line is an index: as R tends to see everything as a vectorized variable (you will see other examples very soon), here it tells us that this 2 is the rst element of the output vector produced by the operation b-a (which contains only one element). On the last line of the above interaction, you can see that even typing a mere value and asking R to evaluate it by pressing the key yields the exact same output with the exact same formatting. 4 1.3 Vectors and function calls As we just said, vectors are essential data structures in R. One creates vectors simply by using the concatenation operator (or function), rightfully named c: > myvec <- c(1,3,5,7,84) # passing five integers as arguments to the function c > myvec # myvec is now a vector containing five elements [1] 1 3 5 7 84 > length(myvec) # calling the function length on the object myvec [1] 5 Here we have just used our rst two functions in R. With the rst command of this interaction block, we performed a function call to the function called c, giving it ve integers as arguments. A function call in R is always written as this: the name of the function is followed by a pair of parentheses enclosing a list of comma-separated arguments (possibly only one or even none). Hence, the last operation we performed above is a function call to the function length, passing to it one argument only, namely the myvec variable. Remember that whenever you want to use a function, you have to write these parentheses. Even if the function needs no argument. For instance, the function ls, when invoked (another vocable computer people use for called) with no argument, lists the content of your current userspace or environment: it returns a vector populated with strings giving the names of these objects present in your current R environment (i.e. the variables you dened earlier in your interactive session). If you omit the parentheses, though, R will try and evaluate the function itself : > ls() [1] "a" "b" "myvec" > ls function (name, pos = -1L, envir = as.environment(pos), all.names = FALSE, .... some complex output clipped off ....
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.