x 012345678 y 01023282513625 Spline interpolation Use Matl

x = [0,1,2,3,4,5,6,7,8];
y = [0,10,23,28,25,13,6,2,-5];

Spline interpolation, Use Matlab code
Write your own spline method to estimate the value of the function on x [0,8],x = 0.1. For your 2 degrees of freedom, set the first and second
derivatives at the left boundary to 0. Save your result, the interpolated y values.(do not use Matlab\'s built-in spline method

Solution

others take much longer). Since the second approach contains N additions, N multiplications and N 1 powers (with our assumption) it takes as much as 4N 2 floating point operations. The third approach takes only N multiplications and N additions for a total of 2N floating point operations. This is the fastest and best approach, specially if N is large, and if the polynomial evaluation is a significant portion of your code (performed possibly millions of times). This approach is called Horner’s rule or nested multiplication. I compared the timings for an example polynomial of degree 20 and found that MATLAB uses about the same amount of time for the second and third approach, probably due to internal optimization when it generates machine code. 2.1.4 Counting operations: evaluating series Let’s implement the function ApproxExp function y=ApproxExp(x,n); % Output parameter: y (nth order Taylor approximation of $e^x$) % Input parameters: x (scalar) % n (integer) sumo = 1; for k=1:n sumo = sumo + x^k/factorial(k); end y = sumo; in a more efficient way using less floating point operations, as follows: function y=ApproxExp2(x,n); % Output parameter: y (nth order Taylor approximation of $e^x$) % Input parameters: x (scalar) % n (integer) temp = 1; 22 sumo = temp; for k=1:n temp = temp*x/k; sumo = sumo + temp; end y = sumo; Note that the second code replaced a power and a factorial by a multiplication and a division, which should be more efficient. The script n=100; x=1; tic ApproxExp(x,n); t1=toc tic ApproxExp2(x,n); t2=toc t1/t2 shows that the second approach is 80 times faster than the first, depending on the values of n and on the machine. 2.2 Machine Representation of real numbers, Roundoff errors 2.2.1 Decimal and binary representation of reals Reals can be represented in base 10 (decimal representation) using digits 0,. . . ,9, or base 2 (binary representation), using digits 0,1, or any other base. Examples next. Example: What number is (1534.4141)10? Example: Find the base 10 representation of (1011.01101)2 Example: Find the first 10 digits of the base 2 representation of 53.710. (Use common sense, no need to learn an algorithm here.)

x = [0,1,2,3,4,5,6,7,8]; y = [0,10,23,28,25,13,6,2,-5]; Spline interpolation, Use Matlab code Write your own spline method to estimate the value of the function

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site