Question

Exercise 4: (Computer Problem) Write a function to implement the following al- gorithm and use your algorithm to find the sol

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER :

clear all
close all

%function for finding root
f=@(x) exp(x)+sin(x)-4;
a=1; b=2; tol=10^-10;

fprintf('function for the algorithm f(x)=')
disp(f)

fprintf('\t e_i \t e_i+1/e_i\t e_i+1/e_i^2\n')
i=0;fc=100; c=10;
while abs(fc)>tol
i=i+1;

fc=double(f(c));
err1=abs(fc);
c=double((b*f(a)-a*f(b))/(f(a)-f(b)));
if f(a)*f(c)<=0
b=c;
else
a=c;
end
err2=abs(f(c));
fprintf('\t%2.2e \t%2.2e \t%2.2e\n',err1,err2/err1,err2/err1^2)

end

OUT PUT :

function for the algorithm f(x)= C(x)exp(x)+sin(x)-4 ei e_i+1/e_i e_1+1/e i 2 2.20 +04 5.86e-06 2.661-10 1.29e-01 2.89e-01 2.

Add a comment
Know the answer?
Add Answer to:
Exercise 4: (Computer Problem) Write a function to implement the following al- gorithm and use your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 4. (6pt) Use the inner product (f,g)f ds to determine the following. (a) Determine if the functio...

    i need help with this linear Algebra question 4. (6pt) Use the inner product (f,g)f ds to determine the following. (a) Determine if the function g(z) = z2-3x + 2 or h(x) = x2-2x + 1 is closest to the fl () is closest to the function f)2+2 on (b, Show that (1,2r - 1) is an orthogonal set (c) Beginning with the basis (1,2 1, 2 (d) Find an orthonormal basis for P2. (e) Find the least squares quadratic...

  • Problem 2 (Eigenvalues and Eigenvectors). (a) If R2 4 R2 be defined by f(x,y) (y,x), then find al...

    Problem 2 (Eigenvalues and Eigenvectors). (a) If R2 4 R2 be defined by f(x,y) (y,x), then find all the eigenvalues and eigenvectors of f Hint: Use the matrix representation. (b) Let U be a vector subspace (U o, V) of a finite dimensional vector space V. Show that there exists a linear transformation V V such that U is not an invariant subspace of f Hence, or otherwise, show that: a vector subspace U-0 or U = V, if and...

  • Consider the following problem: Section II Con n a truth function f, find a statement S, only int...

    Consider the following problem: Section II Con n a truth function f, find a statement S, only intolring the connecti e, ^,V and whose trva function is j. (a) Exhibit an algorithm that solves this problem. (b) Applied the exhibited algorithm to the truth function, 1 given by: TITIT (c) Suppose that the truth function f has n arguments represented by the variables i Consider the first algorithm studied in class to solve the problem of item (a). Let 01,92,.......

  • 3. (20 pts) Do not use a computer to complete the answers for this problem. Show your work in all...

    Please solve the problems (d),(e),(f),(g) 3. (20 pts) Do not use a computer to complete the answers for this problem. Show your work in all problems. Consider the following data: 2 -2 2 1 0 4 0 2 10 0 -2 8 Consider the multiple regression model where ci ~ iid N(0, σ*) for i 1, 2, 3, 4, 5. (a) Fill in the values for response vector, design matrix and coefficient vector: X- (b) Find the vector of least...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • Exercise 6: Given the table of the function f(x)-2" 2 X 0 3 2 f(x) 1 2 4 8 a) Write down the Newton polynomial...

    Exercise 6: Given the table of the function f(x)-2" 2 X 0 3 2 f(x) 1 2 4 8 a) Write down the Newton polynomials P1(x), P2(x), Pa(x). b) Evaluate f(2.5) by using Pa(x). c) Obtain a bound for the errors E1(x), E2(x), Es(x) Exercise 7: Consider f(x)- In(x) use the following formula to answer the given questions '(x) +16-30f+16f,- 12h a) Derive the numerical differentiation formula using Taylor Series and find the truncation error b) Approximate f'(1.2) with h-0.05...

  • Problem 1 Use the trapezoidal rule technique to approximate the following integrals: a) 「(x2+1)d...

    help wanted?? thank you explain correctly Problem 1 Use the trapezoidal rule technique to approximate the following integrals: a) 「(x2+1)dr(Note: use 0.5 increments forx) b) sina d INote: use a MATLAB function to subdivide the interval into eight equal parts) c e dx (Note: use 0.25 increments for x Problem 2 Use the Simpson's rule to evaluate the following integrals aDdr Problem 3: Given the polynomial: x3-6x2 + 30-0, Use MATLAB to find all roots of this polynomial. Use MATLAB's...

  • MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demo...

    MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...

  • Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any a...

    Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any arbitrary function f given an initial guess xo, an absolute error tolerance e and a maximum number of iterations max iter. Follow mynewton.m template posted in homework 2 folder on TritonED for guidance. You are not required to use the template. The function should return the approximated root ^n and the number of steps n taken to reach the solution. Use function mynewton.m to perform...

  • #16.2 Consider the following standard form LP problem: minimize 2xi -x2-^3 subject to 3x1+x2+エ4-4 a. Write down the A,...

    #16.2 Consider the following standard form LP problem: minimize 2xi -x2-^3 subject to 3x1+x2+エ4-4 a. Write down the A, b, and c matrices/vectors for the problem. b. Consider the basis consisting of the third and fourth columns of A, or- dered according to [a4, as]. Compute the canonical tableau correspond ing to this basis c. Write down the basic feasible solution corresponding to the basis above, and its objective function value. d. Write down the values of the reduced cost...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT