Math 451

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What will the value s be after running the following Matlab code? x=[1 4 2 3] y=[4 5 6 7] for i=1:4, for j=1:4 if x(i)==y(j) s=y(j); break end end end

4

Consider the discretization − y i − 1 + 8 y i + y i + 1 = b i . Setting this up into matrix-vector form, A x → = b →, which of the following is clearly FALSE about the coefficient matrix A?

A is a symmetric matrix.

Which of the following Matlab script will NOT solve the following system of linear equations? (1 1 1; 3 2 1; 9 4 1) (x1; x2; x3) = (3; -1; 2)

A=[1 1 1;3 2 1;9 4 1];b=[3;-1;2];x=A/b;

Consider the iteration of the form x^(k + 1) = M x^k + b where x k , b are column vectors of length n, and M is an n × n matrix.If ‖ M ‖ < 1 in some matrix norm, then the iteration only converges with certain initial guess.

False

Consider the system of ODEs x ′ = A x, where A is an n × n matrix and x is a vector of length n. Then, if the eigenvalues of the matrix A satisfy λ 1 = 0.01 , λ 2 = 1890, the system is rather stable with respect to perturbation and thus easy to solve numerically.

False

Fixed point iteration, if convergent, usually converges linearly.

False

Heun's method is of third order.

False

If A = tri-diag ( 3 , − 4 , 2 ), then solving A x = b with Jacobi iteration will converge with small initial guess.

False

If A = tri-diag ( − 1 , 4 , − 1 ), then solving A x = b with Gauss-Seidel iteration will only converge with some initial guess.

False

Consider the iteration of the form x^(k + 1) = M x^k + b where x k , b are column vectors of length n, and M is an n × n matrix.If b = 0 , then the iteration always converges with any initial guess.

False

If we plot the error e of the finite difference method against the grid size h in a log-log plot in Matlab, and obtain a straight line with slope -1, this indicates that the method is of first order.

False

In a least squares method, the sum of the error at every point is minimized.

False

Is the following a quadratic spline? S(x) = { x^2 - 1, 0 <= x <= 1, (x - 1)^2, 1 <= x <= 2

False

Let l 1 ( x ) be the cardinal function associated with the point x 1 for a given set interpolating points ( x 0 , x 1 , x 2 , x 3 ). Then we must have l 1 ( x 1 ) = 0.

False

Newton's iteration for solving f ( x ) = 0 converges if f ′ ( r ) = 0 where r is the root.

False

The Crank Nicholson time step for solving heat equation is a fourth order method.

False

The following computational stencil 1 | 1 - -4 - 1 | 1 is for Finite difference method for Heat equation u t = u x x with Crank-Nicholson time step.

False

The following computational stencil j,n+1 | | j-1,n - - - j,n - - - j+1,n is for Finite difference method for Laplace equation u x x + u y y = 0 with central finite difference.

False

The following finite difference method x i = i h , y i − 1 − ( 2 + h 2 ) y i + y i + 1 = h 2 x i . for the equation y ″ = x + y , y ( 0 ) = 0 , y ( 1 ) = 0 is first order.

False

The following finite difference method x i = i h , y i − 1 − 2 y i + y i + 1 h 2 + y i + 1 − y i h = x i ( 1 − x i ) . for the equation y ″ + y ′ = x ( 1 − x ) , is second order.

False

The following is a two-point boundary value problem: x^2y'' + y = 4x, y(0) = 1, y'(0) = 0

False

The forward Euler step for solving heat equation is always unstable.

False

The function f ( x ) = x − e^x + 4 has a zero on the interval [ 0 , 1 ].

False

We solve a linear two-point boundary value problem using nonlinear shooting method, with secant method at the end. Unfortunately, the secant method will never converge because nonlinear shooting can not be used here.

False

The following computational stencil j - 1, n + 1 --- j, n+1--- j+1, n+1 | | j,n is for Finite difference method for Heat equation T h i s a n s w e r i s s e t a s c o r r e c t with backward Euler time step.

True

If A = tri-diag ( − 1 , − 4 , 1 ), then solving A x = b with SOR iteration with w = 1.2 will always converge for any initial guess.

True

If p ( x ) is a polynomial of degree 6, then p ″ ( x ) is a polynomial of degree 4.

True

The following is an initial value problem: x^2 y ″ + y = 4 x , y ( 8 ) = 1 , y ′ ( 8 ) = 8.

True

The function f ( x ) = x + e^x has a zero on the interval [ − 2 , 1 ].

True

The functions f ( x ) = sin ⁡ ( 2 x ) and g ( x ) = cos ⁡ ( 2 x ) are orthogonal on [ − π , π ] , such that Integrate(pi, -pi, f(x)g(x)dx = 0)

True

The functions g 0 ( x ) = 1 , g 1 ( x ) = x 3 , g 2 ( x ) = x 5 can be used as basis functions in a least squares method.

True

Two-point boundary value problem might have no solutions at all.

True

Perform 2 steps of the iteration x n + 1 = − 1/xsub(n) + 2 with x 0 = − 1, we would get:

x 1 = 3 , x 2 = 5/3

In the linear least squares method, the normal equations are linear equations, and the coefficient matrix is symmetric.

True

Is the following a linear spline? S(x) = { x - 1, 0 <= x <= 1. 0, 1 <= x <= 2

True

Newton iteration is a special kind of fixed point iteration.

True

Secant method, if convergent, has super-linear convergence.

True

Perform 1 step of secant iteration to find the root of f ( x ) = e x − 4 with x 0 = 0, x 1 = 2, we would get:

x 2 = 0.9391

We want to approximate the function f ( x ) = x − 2 on the interval − 2 ≤ x ≤ 2 by a constant function y = c. Which value of c would give the smallest square error?

x = -2

Given the system of equations in matrix form A x = b, where A = [ 1 0 0; 1 2 4; 1 3 9 ] and b = [ 1; 0; − 1 ], to find the solution x we use:

x = A\b

Please complete the following code for solving x^4 − 2 x^2 − 2 = 0 by using Newton's method. x0=0; while 1 if abs(x-x0)<Tol disp('The sequence is convergent!') break end x0=x; end

x = x0 - (x0^4-2*x0^2-2)/(4*x0^3-4*x0);

Consider the ODE x ′ ( t ) = 2 x + t To solve it with Taylor Series method of m = 2 with uniform grid size h, which of the following will be the iteration step?

x k + 1 = x k + h ( 2 x k + k h ) + 1 2 h 2 ( 4 x k + 2 k h + 1 )

Consider the ODE x ′ ( t ) = x + 2 t To solve it with Taylor Series method of m = 1 with uniform grid size h, which of the following will be the iteration step?

x k + 1 = x k + h ( x k + 2 k h )

Convert the given binary number into decimal: (100110)

38

Consider the two-point boundary value problem y ″ ( x ) − 2 y ′ ( x ) = x y , y ( 0 ) = 0 , y ( 1 ) = 1. We discretize the equation using central finite difference, with uniform grid of mesh size h = 1 n, such that y 0 = 0 , y n = 1 , x i = i h. Which of the following is the correct discretization, for i = 1 , 2 , ⋯ , n − 1?

( 1 + h ) y i − 1 − ( 2 + x i h 2 ) y i + ( 1 − h ) y i + 1 = 0

Consider the data set: xi | 1 | 2 | 3 yi | 3 | -1 | 2 Let p ( x ) = a 2 x 2 + a 1 x + a 0 be a polynomial that interpolates the data set. Which of the following linear system would give the solution for ( a 0 , a 1 , a 2 )?

( 1 1 1; 4 2 1; 9 3 1 ) ( a 2; a 1; a 0 ) = ( 3; − 1; 2 )

We want to compute z = x + 4 y in a computer. Let f l ( x ) = x ( 1 + δ x ) and f l ( y ) = y ( 1 + δ y ) be the floating point representations of x and y respectively. What is the propagated error in the relative error in the answer for f l ( z )?

(δz + 4δy)/(x + 4y)

Given the ODE with initial condition x ′ ( t ) = x + t , x ( 1 ) = − 1.5 We solve it with Heun's method, using time step h = 0.02. What is the approximate solution for x ( 1.02 )?

-1.5099

We consider bisection method for finding the root of the function f ( x ) = e^x − 2 on the interval [ − 2 , 2 ]. We perform 2 steps, and our approximations from these two steps are:

0 and 1

What will the following code in Matlab produce? sqrt(-9)

0.0000 + 3.0000i

Given the ODE with initial condition x ′ ( t ) = 3 x + t , x ( 1 ) = 0 We solve it with implicit backward Euler method, using time step h = 0.1. What is the approximate solution for x ( 1.1 )?

0.157

What will the value s be after running the following Matlab code? A=[4 1; -1 -3] s=0; for i=1:2, for j=1:2 s=s+A(i,j); end end

1

Given the interpolating points at ( − 2 , − 1 , 1 , 2 ), which of the following is the cardinal function associated with the point x = 2?

1 /12 ( x + 2 ) ( x + 1 ) ( x − 1 )

What will the following command in Matlab produce? format long e; sqrt(2)

1.414213562373095e+00

Given the ODE with initial condition x ′ ( t ) = x + 2 t , x ( 1 ) = 1 We solve it with forward Euler method, using time step h = 0.1. What is the approximate solution for x ( 1.2 )?

1.65

What will the value i be after running the following Matlab code? t=[1:1:100]; x=10.5; for i=99:-1:1, if (x-t(i)) >= 0, break, end end

10

If you go through the following commands in Matlab: a=[1; 4; 7; 2]; b=[2 6 8 9 10 0 -1]; c=min(a)+max(b); What value(s) will be in c?

11

Convert 30 from decimal to binary.

11110

Assume that the iteration xsub(n + 1) = − 1/2*xsub(n) + 9/4 converges. What is lim n → ∞ x n?

2

If you are given a matrix A = [ 1 2 3; 4 5 6; 7 8 9 ], what is A(1,2)?

2

We want to compute z = 3 x + y in a computer. Let f l ( x ) = x ( 1 + δ x ) and f l ( y ) = y ( 1 + δ y ) be the floating point representations of x and y respectively. What is the propagated error in the absolute error in the answer for f l ( z )?

3 x (δ x) + y (δ y)

Consider the equation u t = 4 u x x with the numerical scheme u i n + 1 − u i n Δ t = 4 u i − 1 n + 1 − 2 u i n + 1 + u i + 1 n + 1 ( Δ x ) 2 What method is this?

Backward Euler, an implicit method

What will the following code produce in Matlab? C=cat(3,[1 1; 2 2; 3 3], [5 5 ; 7 7; 9 9]); C(:,:,1)

C(;,;,1)= 1 1 2 2 3 3

Find the value a that will make the following a natural cubic spline: S ( x ) = { x^3 , 0 ≤ x ≤ 1 , ( x − 2 ) 3 + a , 1 ≤ x ≤ 2. If the value does not exist, then state DNE.

DNE

Let f ( x ) be a function which has a Taylor series about x = 1, and let f 7 ( x ) be the partial sum of the first 8 terms. What is an estimated bound for the error E 8 = | f ( x ) − f 7 ( x ) |?

E 8 ≤ 1/8! f^( 8 ) ( ξ ) ( x − 1 )^8 for some ξ between x and 1.

What will the following code produce in Matlab? A=rand(3,3); b=rand(1,3); c=A*b

Error message

Bisection method always converges given that the initial guess is sufficiently close to the root.

False

Consider the following computational stencil j-1,n+1 - - - j, n+1 - - - j+1, n+1 | | j-1,n - - - j,n - - - j+1,n It is for Finite difference method for Laplace equation u x x + u y y = 0 with central finite difference.

False

Consider the iteration of the form x^ (k + 1) = M x^k + b where x k , b are column vectors of length n, and M is an n × n matrix. If M is invertible, then the iteration always converges with any initial guess.

False

Consider the piecewise polynomial S ( x ) = { S 0 ( x ) , t 0 ≤ x ≤ t 1 , S 1 ( x ) , t 1 ≤ x ≤ t 2 , ⋮ S n − 1 ( x ) , t n − 1 ≤ x ≤ t n . Which of the following statement will make S ( x ) NOT a linear spline?

For some T h i s a n s w e r i s s e t a s c o r r e c t, we have .S i ( t i + 1 ) = 2, S i + 1 ( t i + 1 ) = 0.

Consider the piecewise polynomial, S ( x ) = { S 0 ( x ) , t 0 ≤ x ≤ t 1 , S 1 ( x ) , t 1 ≤ x ≤ t 2 , ⋮ S n − 1 ( x ) , t n − 1 ≤ x ≤ t n . Which of the following statement will make S ( x ) NOT a natural cubic spline?

For some T h i s a n s w e r i s s e t a s c o r r e c t, we have S i ( t i + 1 ) = 0, S i + 1 ( t i + 1 ) = 1.

The following function will be hard to compute for what values of x? f(x) - 1/(sqrt(x^2 + 3) - x)

For x large and positive.

What does the command "hold on" do?

Freezes the current plot so that subsequent graphs will be displayed with the current.

What does the following command do in Matlab? A=rand(6,6); [L,U]= lu(A)

It computes the LU factorization of the matrix A.

What does the command A=sparse(5,9) do in Matlab?

It generates a 5x9 sparse matrix with all 0 entries, and stores it in A.

What does the following code do in Matlab? if x<=1, error('The value for x is less than or equal 1'), end

It produces an error message if x <=1.

Consider the following ODE with initial condition x ′ = 3 x − t , x ( 1 ) = 1 We solve it with Heun's method, with uniform time step h and initial values t 0 = 1 , x 0 = 1. Which of the following is the formula for step n?

K 1 = h ( 3 x n − t n ) , K 2 = h ( 3 x n + 3 K 1 − t n + 1 ) , x n + 1 = x n + 1 2 ( K 1 + K 2 )

Given the splitting of a square matrix A = L + D + U where L is lower triangular, D is diagonal, and U is upper triangular. The Jacobi iteration can be written in the general form x^(k + 1) = M x^k + y with which choice of ( M , y )?

M = − D^−1 ( L + U ) , y = D^−1 b

Assign variable "M" as the matrix [1,2,3;4,5,6]

M=[1,2,3;4,5,6]

Let y ¯ ( x ) and y ~ ( x ) solve the equations y ¯ ‴ + 2 ( y ¯ ′ ) 2 = e x , y ~ ‴ + 2 ( y ~ ′ ) 2 = e x . Then, the function y = ( 1 − λ ) y ¯ + λ y ~ solves which equation?

None of the other answers here.

Let y ¯ ( x ) and y ~ ( x ) solve the equations y ¯ ‴ + x y ¯ ′ = e^x , y ~ ‴ + 2 x y ~ ′ = e^x . Then, the function y = ( 1 − λ ) y ¯ + λ y ~ solves which equation?

None of the other answers here.

Given a function ϕ ( a , b ), at its minimum ( a ¯ , b ¯ ), which of the following must hold?

None of these.

What type of equation is the following? Uxx + Uyy = xy

Poisson equation in 2D

Given that A is 10x20 matrix in Matlab, possibly with many zero elements. What does the code S=sparse(A) produce?

S will be a sparse matrix which stores only the non-zero elements of A, to save memory space.

Which of the following code will generate a 100x100 tri-diagonal matrix A, with 2 on the diagonal, and -1 on the upper and lower diagonal, and stores it as a sparse matrix in the variable T?

T=spdiags([-ones(100,1) 2*ones(100,1) -ones(100,1)],[-1,0,1],100,100)

Consider the discretization a i y i − 1 + d i y i + c i y i + 1 = b i . Setting this up into matrix-vector form, A x → = b →. ThenA is a tri-diagonal matrix with d i on the diagonal.

True

For the Taylor series method with order m, the local truncation error is formally of order m + 1.

True

Forward Euler step is conditionally stable.

True

Let p ( x ) be the Lagrange form and q ( x ) be the Newton's form of the interpolating polynomial for the same data set ( x i , y i ) i = 0 n. Then we must have p ( x ) = q ( x ) for every x.

True by the Uniqueness Thereom

Consider the discrete equation u i − 1 , j − 2 u i , j + u i + 1 , j/h 2 + 2 u i , j − 1 − 4 (u i , j + 2 u i , j + 1)/h 2 − 4( u i + 1 , j − u i − 1 , j) /2h + u i , j = 0. Which PDE could correspond to this discretization?

Uxx + 2Uyy - 4Ux + U = 0

Given a 3x3 matrix A, what does [V,D]=eig(A) produce in Matlab?

V is a 3x3 matrix that contains the 3 eigenvectors of a, and D is a diagonal matrix with the eigenvalues of A on the diagonal.

We solve the following ODE with finite difference method u ″ = 0 , u ( 0 ) = 1 , u ( 1 ) = 1. Discretize with uniform grid, with h = 0.2 and x i = i h for i = 0 , 1 , 2 , 3 , 4 , 5. What will be the final system of linear equations to solve for the discrete unknowns?

[ − 2 1 0 0 1 − 2 1 0 1; − 2 1 1 − 2 ] [ u 1 u 2 u 3 u 4 ] = [ − 1 0 0 − 1 ]

Assign variable "a" as a column vector of length 4, [1;2;3;4]

a = [1;2;3;4]

Given the error function ψ ( a , b ) = ∑ k = 0 m ( a sin ⁡ ( x k ) + b )^2 , the normal equations that will find the values of ( a , b ) which minimize the error will look like:

a ⋅ ∑ k = 0 m ( sin ⁡ x k ) 2 + b ⋅ ∑ k = 0 m sin ⁡ x k = 0 , a ⋅ ∑ k = 0 m sin ⁡ x k + ( m + 1 ) b = 0 .

What will the following Matlab command produce? feval('sqrt',9)

ans = 3

What will the following command produce in Matlab? 10==9

ans =( logical) 0

We want to approximate the function f ( x ) = x 4 on the interval 0 ≤ x ≤ 1 by a linear function y = c x. Which value of c would give the smallest square error?

c = 1/2

For a given data set { x i , y i } , i = 0 , 1 , ⋯ , m, we want to approximate it by a function y = c x with least square method. Which one gives us the c value?

c = ∑ i = 0 m x i y i/(∑ i = 0 m x i 2)

Given the data set [ x k , y k ] k = 0 m, what constant c makes the expression ∑ k = 0 m ( y k − c x k ) 2 as small as possible?

c = ∑ k = 0 m y k x k/( ∑ k = 0 m x k 2)

What will the following Matlab code produce? x=[1 2 3 4 5 6 7 8]; dx=x(2:8)-x(1:7)

dx = 1 1 1 1 1 1 1

Assuming that we are performing a Newton iteration which converges quadratically. Let e k be the absolute error of iteration step k. Which of the following could be possible errors for the first 3 iterations?

e 0 = 0.11 , e 1 = 0.0121 , e 2 = 0.00014

Create a 10 × 10 identity matrix

eye(10)

For a given data set { x i , y i } , i = 0 , 1 , ⋯ , m, we want to approximate it by a function f ( x ) with least square method. We have the error function ψ ( a , b ) = ∑ i = 0 m ( a x i + b − y i )^2 Find the function f ( x ).

f ( x ) = a x + b

For the function f ( x ) = 1 /(2 | x | − sqrt(4 x ^2 + 1)) when it is hard to compute, which equivalent function would you rather use to compute f ( x ) accurately?

f ( x ) = −sqrt( 4 x^2 + 1) − 2 | x |

Which of the following is pattern of the "for loop" in Matlab?

for i=1:10, disp(i^2), end

Given a vector t = [100:-1:1], and a number x ∈ [ 1 , 100 ), write a Matlab script that finds the index i such that t(i) > x ≥ t(i+1).

for i=1:99 if (t(i)-x)*(t(i+1)-x)<=0 break; end end disp('the index is ') i

Perform 1 step of Newton iteration to find the root of f ( x ) = e^x − 2 with x 0 = 1, we would get:

x 1 = 0.7358

Define a Matlab function that takes a vector x as input, and returns a vector y which contains the value of the function x 2 + x e x. Make sure to use the vector operations. Which of the following definition is correct?

function y=myfun(x) y=x.^2+x.*exp(x); end

Which Matlab function will take ( x , t ) as input variables and y as the output variable that returns the value y = F ( x , t ) = − sqrt(3 x^2 + 1) + t/x^2 ?

function y=myfun(x,t) y=-sqrt(3*x^2+1)+t/(x^2) end

Which code will assign value 2 to t if x is bigger than 0?

if x>0, t=2; end

To create vectors with logarithmically spaced entries, which command should we use?

logspace(0,1,11)

What will the following code produce in Matlab? x=[1 4 5]; n=length(x)

n = 3

What will the following commands in Matlab give? A=[1 2 3; 4 5 6]; n=size(A,1)

n=2

Given a vector v, which of the following code will return the 2-norm of vector v?

norm(v)

We use Newton's divided difference to write out the Newton's form for the polynomial p ( x ) that interpolates the data set xi | 0 | 1 | 2 yi | -5 | -1 | 9 Which one is the correct Newton's polynomial, without simplifying?

p ( x ) = − 5 + 4 x + 3 x ( x − 1 )

Recall the nested form for Newton's polynomial p ( x ) = a 0 + ( x − x 0 ) ( a 1 + ( x − x 1 ) ( a 2 + ( x − x 2 ) ( a 3 + ⋯ + a n ( x − x n − 1 ) ) ) ) The following Matlab program computes the value of this polynomial: function p=nestedNewton(a,xp,x) // input: // a -- vector for a_n values // xp -- vector for x_n values // x -- the point x where p(x) is evaluated // output: // p -- the value p(x) n=length(a); p=a(n); for k=n1:-1:1 // missing content for the for-loop end Fill in the Matlab code that is missing in the for-loop.

p=p*(x-x(k))+a(k);

The polynomial p ( x ) = x 4 + x 2 − 8 has the values shown. x | − 2 | − 1 | 0 | 1 | 2 p ( x ) | 12 | − 6 | − 8 | − 6 | 12 Find a polynomial q ( x ) of degree 4 that takes these values x | -2 | -1 | 0 | 1 | 2 q(x) | 12 | -6 | -8 | -6 | 9

q ( x ) = p ( x ) − 1/8 ( x + 2 ) ( x + 1 ) x ( x − 1 )

The functions f ( x ) = sin ⁡ ( 1/2 x ) and g ( x ) = cos ⁡ ( 1/3 x ) − 1 are orthogonal on [ − π , π ] , such that integrate (pi, -pi, f(x) g(x) dx = 0

true

Which of the following is for sure a uniform grid for time { t k } k = 0 N , with grid size h?

tsub(k + 1) − tsub(k) = h

We solve the following equation with forward Euler u t = u x x − u Which of the following is the numerical scheme, with uniform mesh of size Δ x , Δ t?

u i n + 1 = u i n + Δ t ( Δ x ) 2 [ u i − 1 n − 2 u i n + u i + 1 n ] − Δ t u i n

We solve the follow equation with Crank-Nicolson scheme u t = u x x − 2 u Which of the following is the correct numerical scheme for uniform mesh with Δ x , Δ t?

u i n + 1 − u i n Δ t = u i − 1 n − 2 u i n + u i + 1 n 2 ( Δ x ) 2 + u i − 1 n + 1 − 2 u i n + 1 + u i + 1 n + 1 2 ( Δ x ) 2 − ( u i n + u i n + 1 )

Consider the PDE u x x + 2 u y y − 2 u x + 4 u y = 0 , 0 ≤ x ≤ 1 , 0 ≤ y ≤ 1. Using second order central finite difference, and uniform grid in both x and y with n interval and h=1/n, which of the following is the correct discrete equation, for 1 ≤ i ≤ n − 1 , 1 ≤ j ≤ n − 1?

u i − 1 , j + 2 u i , j − 1 − 6 u i , j + u i + 1 , j + 2 u i , j + 1 − h ( u i + 1 , j − u i − 1 , j ) + 2 h ( u i , j + 1 − u i , j − 1 ) = 0

Consider the heat equation with source term u t = u x x , 0 ≤ x ≤ 1 , t ≥ 0. Setting up the finite difference method, using backward Euler time step, which of the following will be the correct discretization?

u j n + 1 = u j n + Δ t ( Δ x ) 2 ( u j − 1 n + 1 − 2 u j n + 1 + u j + 1 n + 1 ) .

Which of the following function is the solution for the following ODE with initial condition? x'(t) = 2x + 2, x(0) = 2

x ( t ) = 3 e^(2 t) − 1

Which of the following is the McLaurin series for x e^x?

x + x^2 + x^3/2 + x^4/3! + x^5/4! + ⋯

Consider the following ODE with initial condition x ′ = x − t , x ( 1 ) = 1 We solve it with implicit backward Euler method, with uniform time step h and initial values t 0 = 1 , x 0 = 1. Which of the following is the formula for step n?

x n + 1 = ( 1 − h ) − 1 ( x n − h t n + 1 )

Which of the following Matlab code will plot the graph for the function y = 1/( 1 + x) on the interval 0 ≤ x ≤ 1 ?

x=(0:0.01:1); y=1./(1+x); plot(x,y)

Which Matlab script will NOT plot the function y = 3xe^x on the interval 0 ≤ x ≤ 1 ?

x=0:0.01:1; y=3x.*exp(x); plot(x,y)

Let x=10. Write a while loop which reduces x to half of its value, until it is less than 1. Which of the following code will work?

x=10; while x >= 1, x=x/2; end

Given the splitting of a square matrix A = L + D + U, where L is lower triangular, D is diagonal, and U is upper triangular, which of the following formula is the SOR iteration for solving A x = b with relaxation parameter w?

x^(k + 1) = ( 1 − w ) x^k + w D^−1 ( b − L x^(k + 1) − U x^k )

Consider the system of linear equations { 4 x + y = 6 x + 4 y = 1 Performing one step SOR iteration using w = 1.4 and with initial guess x^0 = 1 , y^0 = 1, we will get:

x^1 = 1.35 , y^1 = − 0.5225

Consider the system of linear equations { 2 x + y = 6 x + 2 y = 10 Performing one step Gauss-Seidel iteration with initial guess x 0 = 0 , y 0 = 1 , we will get:

x^1 = 2.5 , y^1 = 3.75

Consider the system of linear equations { 3 x + y = 9 x + 3 y = 6 Performing one step Jacobi iteration with initial guess x 0 = 0 , y 0 = 0 , we will get:

x^1 = 3 , y^1 = 2

Find a constant function y = c that best fit the data with least square error xi | -2 | -1 yi | 3 | 5

y = 4

Find a linear function y = c x that best fits the data with least square error xi | 1 | 4 yi | -2 | 2

y = 6/17 x

Consider the two-point boundary value problem y ″ ( x ) = x 2 y , y ( 0 ) = 0 , y ( 1 ) = 1. We will solve it with finite difference method, using uniform grid with n points and mesh size h = 1 n, such that y 0 = 0 , y n = 1 , x i = i h. Which of the following is the correct discretization, for i = 1 , 2 , ⋯ , n − 1?

y i − 1 − ( 2 + x i 2 h 2 ) y i + y i + 1 = 0

Assign variable y as sin(4x^2 + 1)

y=sin(4*x^2+1);

Find the interpolating polynomial for the given data set xi | -2 | 0 | 2 yi | -3 | -1 | 1

y=x-1

Consider the system of linear equations { 4 x − y − z = 8 − x + 5 y − z = 4 − x − y + 6 z = 2 Which of the following is the Gauss-Seidel iteration for step k ?

{ 4 x^(k + 1) = 8 + y^k + z^k 5 y^(k + 1) = 4 + x^(k + 1) + z^k 6 z^(k + 1) = 2 + x^(k + 1) + y^(k + 1)

Consider the system of linear equations { 4 x + y + z = 8 x + 4 y + z = 4 x + y + 4 z = 2 Which of the following is the SOR iteration with relaxation parameter w, for step k ?

{ x^(k + 1) = ( 1 − w ) x^k + w/4 ( 8 − y^k − z^k ) y^(k + 1) = ( 1 − w ) y^k + w/4 ( 4 − x^(k + 1) − z^k ) z^(k + 1) = ( 1 − w ) z^k + w/4 ( 2 − x^(k + 1) − y^(k + 1) )

Consider the system of linear equations { − 4 x + y + z = 1 x − 4 y + z = 2 x + y − 4 z = 4 Which of the following is the Jacobi iteration for step k ?

{ − 4 x^(k + 1) = 1 − y^k − z^k − 4 y^(k + 1) = 2 − x^k − z^k − 4 z^(k + 1) = 4 − x^k − y^k

Given the initial value problem x ″ = 2 ( x ′ ) 2 + x t , x ( 0 ) = 1 , x ′ ( 0 ) = 2. One can rewrite it into a system of first order ODEs using the variable change x 1 = x , x 2 = x ′. Which of the following system is correct?

{ x 1 ′ = x 2 x 2 ′ = 2 ( x 2 ) 2 + x 1 t , { x 1 ( 0 ) = 1 x 2 ( 0 ) = 2 .

We want to solve the following equation with 2nd order ABM method x ′ ( t ) = x + t Given x 0 , x 1, the time step at step n ≥ 2 will look like:

{ x n + 1 ∗ = x n + h [ 3 2 ( x n + n h ) − 1 2 ( x n − 1 + ( n − 1 ) h ) ] x n + 1 = x n + h 2 [ ( x n + 1 ∗ + ( n + 1 ) h ) + ( x n + n h ) ] .

An interpolating polynomial of degree 5 is to be used to approximate f ( x ) = 2 cos ⁡ ( π x ) on the interval 0 ≤ x ≤ 1. Which of the following is an upper bound for the error?

| e ( x ) | ≤ 2/( 6 !) * π^6

We solve the heat equation u t = 4 u x x , with finite difference method using forward Euler time step. What is the CFL stability condition?

Δ t ≤ 1/8 ( Δ x )^2 .

Consider the two-point boundary value problem: y ″ ( x ) = 4 y + x , y ′ ( 0 ) = 1 , y ′ ( 2 ) = − 3. To solve it with shooting method, we let y ¯ ( x ) be the solution of y ¯ ″ ( x ) = 4 y ¯ + x , y ¯ ′ ( 0 ) = 1 , y ¯ ( 0 ) = 0 , and let y ~ ( x ) be the solution of y ~ ″ ( x ) = 4 y ~ + x , y ~ ′ ( 0 ) = 1 , y ~ ( 0 ) = 1. Let now y = λ y ¯ + ( 1 − λ ) y ~ . For what value of λ will this y be the solution of the two point boundary value problem?

λ = − 3 − y ~ ′ ( 2 ) / (y ¯ ′ ( 2 ) − y ~ ′ ( 2 ) )

Given data set [ x k , y k ]m k = 0, to best fit in the function g ( x ) = a x 3 + b ( x + 1 ) 2, what will be the error function ψ ( a , b ) that we minimize?

ψ ( a , b ) = ∑ k = 0 m ( a x k 3 + b ( x k + 1 ) 2 − y k ) 2

Consider the 2D Poisson equation on a unit square u x x + u y y = 4 , 0 ≤ x , y ≤ 1 , with boundary conditions u x ( 0 , y ) = 0 , u ( 1 , y ) = u ( x , 0 ) = u ( x , 1 ) = 0. Note the Neumann boundary condition along x = 0. Treating this with ghost boundary, using uniform grid with grid size h, which of the following discrete equation is correct?

− 4 u 0 , j + 2 u 1 , j + u 0 , j − 1 + u 0 , j + 1 = 4 h 2


Ensembles d'études connexes

International Business Midterm (set 2/2)

View Set

Ch. 15: Managing Marketing Channels and Supply Chains

View Set

Appendix B4 - Joint and conditional distribution

View Set

My review for Business Benchmark

View Set

Chapter 7: Access Control List (NetAcad) (Exam)

View Set

EMT Chapter 27 Quiz - Soft Tissue Injuries

View Set

Leadership Final Exam ch. 14, 18, 19, 25, 6, 17, 5, 7, 27, 26, 31

View Set