Write a MATLAB function that evaluates a polynomial function f(x) = ax+aN_x1 + ...ax + ao...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a MATLAB function that evaluates a polynomial function f(x) = ax+aN_x1 + ...ax + ao of order N for a scalar value x. The function should take a 1 by N+1 array (index 1 to N+1 to be N+1 terms) containing the polynomial coefficients and a scalar value x, and should return the polynomial function value f(x). The coefficient ay for the highest power of x is the first element of the coefficient array and the coefficient an is the last element of the coefficient array. A sample polynomial function f(x) = 3.5x + 1.5 and value x = 1.0 would look like: a = [3.5, 1.5]; x = 1.0; then implement your function Use a loop (while or for) to calculate the result. Think about how will you implement it using element-by-element operation yourself, do not implement it here. Do not use sum in calculating your result. The input of your function is a and x, that will define the polynomial function. The output of your function is y. function y = myFunction(a, x) Test the function for the following cases on your own MATLAB installation. f(x) = 3.5x+1.5 for x = 0 f(x) = 3.5x + 1.5 for x = 3 f(x)=x-2.5x + 0.7 for x = 0 f(x)=x-2.5x+0.7 for x = -2 " B Your function should work for any possible test cases passed through a and x, not just the above ones. Write a MATLAB function that evaluates a polynomial function f(x) = ax+aN_x1 + ...ax + ao of order N for a scalar value x. The function should take a 1 by N+1 array (index 1 to N+1 to be N+1 terms) containing the polynomial coefficients and a scalar value x, and should return the polynomial function value f(x). The coefficient ay for the highest power of x is the first element of the coefficient array and the coefficient an is the last element of the coefficient array. A sample polynomial function f(x) = 3.5x + 1.5 and value x = 1.0 would look like: a = [3.5, 1.5]; x = 1.0; then implement your function Use a loop (while or for) to calculate the result. Think about how will you implement it using element-by-element operation yourself, do not implement it here. Do not use sum in calculating your result. The input of your function is a and x, that will define the polynomial function. The output of your function is y. function y = myFunction(a, x) Test the function for the following cases on your own MATLAB installation. f(x) = 3.5x+1.5 for x = 0 f(x) = 3.5x + 1.5 for x = 3 f(x)=x-2.5x + 0.7 for x = 0 f(x)=x-2.5x+0.7 for x = -2 " B Your function should work for any possible test cases passed through a and x, not just the above ones.
Expert Answer:
Answer rating: 100% (QA)
The question in the image asks for a MATLAB function that evaluates a polynomial function of the for... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Does the EOQ increase or decrease if estimates of setup (order) costs include fixed, semi-variable, and pure variable costs while inventory-holding costs includes only pure variable costs? Vice...
-
Morrow Corporation had only one job in process during May-Job X32Z-and had no finished goods inventory on May 1. Job X32Z was started in April and finished during May. Data concerning that job appear...
-
Distinguish between questions of law and questions of fact, and explain why this distinction is significant.
-
Electromagnetic waves in certain wavelength ranges interact with water molecules because the molecules have a large electric dipole moment. The electric field of the wave A. Exerts a net force on the...
-
Ben Bates graduated from college six years ago with a finance undergraduate degree. Although he is satisfied with his current job, his goal is to become an investment banker. He feels that an MBA...
-
5. Oil is leaking from a pipeline on the surface of Laguna Lake and forms an oil slick whose volume increases at a constant rate of 2000 cm/min. The oil slick takes the form of a right circular...
-
Discuss your E-Commerce experience with websites and shopping carts, as a user? What websites and shopping carts features do you find useful or irritating?
-
Find the equivalent capacitance of the network as shown, A 3F HH 3F HH B 3F 3F
-
import java.util.Random; public class App { public static void main(String[] args) throws Exception { // The following is to help make your lists, please DO NOT DELETE THIS. Random random = new...
-
The Problem: Why Countless Start-Ups Fail in the United States. An application of strategic planning concepts to professional and academic contexts. Your application should include answers to the...
-
import java.util.Scanner; class HammingCode { static void print ( int ar [ ] ) { for ( int i = 1 ; i < ar . length; i + + ) { System.out.print ( ar [ i ] ) ; } System.out.println ( ) ; } static int [...
-
Explain why small business owners need to pay attention to employee turnover rates in their companies. Discuss two cost-effective strategies that they can implement to reduce employee turnover.
-
You have the opportunity to purchase a facility that manufactures laptops. If you purchase this facility, you expect to sell 100,000 laptops per year for the next 10 years. The profit per laptop is...
-
Calculate Total Contribution Margin for the same items. Total Revenue Total Variable Costs Total Contribution Margin $50.00 a. $116.00 $329.70 b. $275.00 $14,796.00 $7,440.00 c. $40,931.25 d....
-
Use predictorcorrector to integrate subject to the initial condition y(0) = 1. dy dx =xy/2 (4.2.53)
-
Compute the convergence of successive relaxation for the problem in Eq. (2.13.7) as a function of the relaxation parameter . 2x1 + x = 2 x1 - 2x = -2 (2.13.7)
-
Use Cramers rule to compute the solution to the system of equations 2x+y=z=1 -x+ 2z = 4 4x - 2y + 3z0
-
Consider the following time series data. a. Construct a time series plot. What type of pattern exists in the data? b. Show the four-quarter and centered moving average values for this time series. c....
-
The following table reports prices and usage quantities for two items in 2009 and 2011. a. Compute price relatives for each item in 2011 using 2009 as the base period. b. Compute an unweighted...
-
Refer to exercise 35. a. Deseasonalize the time series using the adjusted seasonal indexes computed in part (c) of exercise 35. b. Using Minitab or Excel, compute the linear trend regression equation...
Study smarter with the SolutionInn App