Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NANO 15/CENG 15: Homework 7 Due on Wednesday, November 18th Problem 1: A mathematical relationship between x and y is described by the following expressions:
NANO 15/CENG 15: Homework 7 Due on Wednesday, November 18th Problem 1: A mathematical relationship between x and y is described by the following expressions: y=A*exp(x^2)-B*x^3+x-1 if x<=0 (Case 1) y=A*log10(x)-B*x^4+1.5 if 010 (Case 3) where A, B, and C are constants. Write a program that inputs the constants A,B,C, and the argument x, and computes the corresponding value of y. Print x by using 4 decimal places, and y by using 5 decimal places. Use if/else statements to choose the proper expression for y, corresponding to selected x. After reading A,B,C, your program should use a while loop to evaluate y for scanned x in each of the above three cases. If you input x from the same interval again, your program should ask you to input x from another interval, until you input x once from each interval. Your output should look like: Enter A, B, C: -1.5 2.5 0.125 Enter x: -3.5 Case 1 x value is = -3.5000 and y value is = -313369.24580 Enter x: -5 Enter x from another interval! Enter x: 1.85 Case 2 x value is = 1.8500 and y value is = -28.18452 Enter x: 12 Case 3 x value is = 12.0000 and y value is = -0.68698 Problem 2: Write your own matlab code that will find the roots (or zeroes) of a given function by using the Newton-Raphson method discussed in class. This method is based on the following: one starts with an initial guess, then the function is approximated by its tangent line, and one computes the intercept of this tangent line with the x-axis. This x-intercept will typically be a better approximation to the function's root than the original guess. Iterate the method until you reach the prescribed tolerance, say abs(y)<=0.0001. Find all roots of y=x^4-x-4 and print them with 4 decimal places
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started