Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

MATH 1110H - Fall 2018

Project: Test
Views: 105
################################################### # Question 1 ################################################### x = var('x') plot(1/x, (-5,5), ymin = -5, ymax = 5, aspect_ratio = 1) # plot y = 1/x between x=-5 and x=5 # setting the aspect ratio to 1 makes sure the x and y axes are scaled the same
plot(sqrt(x), (0,5), ymin = -0.5, ymax = 2.5, aspect_ratio = 1) # plot y = sqrt(x) between x=0 and x=5 (negative values are not in the domain of sqrt)
plot(sin(x), (-5,5)) #plot y = sin(x) between x=-5 and x=5
plot(cos(x), (-5,5)) # plot y = cos(x) between x=-5 and x=5
################################################### # Question 2 ################################################### plot([sin(x), cos(x), sin(x+pi/4), cos(x+pi/4)], (-5,5), legend_label = ['y=sin(x)', 'y=cos(x)', 'y=sin(x+pi/4)', 'y=cos(x+pi/4)'])
################################################### # Question 3 ################################################### plot([sin(2*x), 2*sin(x)*cos(x)], (-pi,pi), linestyle = ["-","--"], thickness = 2, legend_label = ['y=sin(2x)', 'y=2sin(x)cos(x)'])
# we plot y = sin(2x) and y = 2sin(x)cos(x) from x = -pi to x = pi. We choose this range because sin(2x) is periodic with period pi, so this range is more than enough to see the full behaviour of the function. The output supports the fact that sin(2x) and 2sin(x)cos(x) are the same function. We plotted the second with dashed lines ("--") and the first with solid lines ("-") so we could see both plots, even though the graphs are the same. ################################################### # Question 4 ################################################### x_range = (-5,5) # the range of x values we'll use for each of the following plots p1 = plot(x, x_range, color = 'blue', legend_label = 'y = x') p2 = plot(x-x^3/factorial(3), x_range, color = 'green', legend_label = 'y = x - x^3/3!') p3 = plot(x-x^3/factorial(3)+x^5/factorial(5), x_range, color = 'red', legend_label = 'y = x - x^3/3! + x^5/5!') p4 = plot(x-x^3/factorial(3)+x^5/factorial(5)-x^7/factorial(7), x_range, color = 'purple', legend_label = 'y = x - x^3/3! + x^5/5! - x^7/7!') p5 = plot(sin(x), x_range, color = 'orange', legend_label = 'y = sin(x)') show(p1 + p2 + p3 + p4 + p5, ymin = -5, ymax = 5) # shows all the plots defined above