% Bayesian Data Analysis
% Fall 2018
% HW1p: Programming Homework #1
% Instructor: Dr. Kevin H. Knuth
% Date : 4 Sep 2018
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Your programming HW must be accompanied by a PDF write up that
% summarizes your work and results, including all required figures
% along with accompanied figure captions providing a description
% and explanation.
%
% a) Write a SCRIPT to verify that computers do indeed make mistakes
% - Create a loop that adds 0.1 to a variable 10 times
% - Display the result
% - Does this give you the correct answer of 0.1 * 10 = 1?
% - ARE YOU SURE ITS CORRECT? Try subtracting 1.0 to see the difference
% - How large is the error in the calculation?
%
% b) Write a SCRIPT where you vectorize the above code:
% - Create a 1x10 vector of values equal to 0.1
% - Use the sum function to sum them
% - What is the error in this case?
% - Use the functions 'tic' and 'toc' to determine how much faster
% or slower the vectorized code is compared to the above code. Note that
% you may have to loop through the calculation many times to get
% a good estimate. Make sure you get a good estimate!
%
% c) Write a FUNCTION called mySINE to be used as such: y = mySINE(x)
% to compute the values of sin(x) correct to three decimal places.
% Use the Taylor series below to do this. How many terms will you need
% to make sure that the result is accurate to three decimal places?
% sin(x) = x - x^3/3! + x^5/5! + ...
% - Prepend the function header below to your function and fill in the
% details as instructed.
% USE THIS HEADER TEMPLATE FOR ALL FUNCTIONS!
%
% d) Write a SCRIPT that compares mySINE() to MATLAB's function sin()
% - On a SINGLE plot display the sin from 0 to 2pi using each function
% Color MATLAB's sin() function using RED
% Color your mySINE() function using BLUE
% - Create a second plot showing the difference between the two functions
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% FUNCTION HEADER EXAMPLE %%%%
%%%% PREPEND THIS TO EVERY FUNCTION %%%%
% ENTER FUNCTION NAME HERE
% ENTER TEXT DESCRIBING WHAT THE FUNCTION DOES
%
% Usage:
% function [ output_args ] = Untitled2( input_args )
%
% Where:
% input_args = LIST AND DESCRIBE THEM
% output_args = LIST AND DESCRIBE THEM
%
% ENTER ANY ADDITIONAL NOTES
%
% Created By:
% ENTER YOUR NAME
% ENTER THE DATE
%
% ENTER MODIFICATION INFORMATION HERE