quiz5_solution

# Quiz5_solution - Introduction to Computational Physics Phy 265 Homework Quiz 5(Take-Home Solutions Question 1 S=solve'x^2-4*y=12'5*x y=8 S = x[2x1

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Computational Physics Phy 265 Homework Quiz 5 (Take-Home) Solutions Question 1: S=solve('x^2-4*y=12','5*x+y=8') S = x: [2x1 sym] y: [2x1 sym] >> S.x ans = 2 -22 ans = -2 118 Solutions are (2,-2) and (-22,118) Question 2: >> S=solve('x+3*y-z=2','x-y+z=3','3*x-5*y=4') S = x: [1x1 sym] y: [1x1 sym] z: [1x1 sym] >> S.x ans = 33/16 >> S.y ans = 7/16 >> S.z ans = 11/8 Solution is (33/16,7/16,11/8) 1 Question 3: >> syms x >> int(exp(-x),0,inf) ans = 1 >> int(exp(-x^2),0,inf) ans = pi^(1/2)/2 Question 4: >> f = @(x) x^2 - sin(x) + x^(-1) f = @(x)x^2-sin(x)+x^(-1) >> f(0) ans = Inf >> f(1) ans = 1.1585 >> f(pi/2) ans = 2.1040 >>f = @(x) x.^2 - sin(x) + x.^-1 >>x = linspace(-1,1); >>y = f(x); >>plot(x,y,'-r'); >>xlabel('x'); >>ylabel('y'); >>title('f(x) = x^2 - sin(x) +1/x'); 2 3 ...
View Full Document

## This note was uploaded on 02/23/2012 for the course PHYSICS 265 taught by Professor Tegler during the Spring '11 term at N. Arizona.

Ask a homework question - tutors are online