Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

1 Newton’s method Newton’s method is a root-finding algorithm. The way it works is pretty simple. Let f be a differentiable function for all x ∈ R. Pick a starting point, x0. Then we compute x1 = x0 −...

1 answer below »
1 Newton’s method
Newton’s method is a root-finding algorithm. The way it works is pretty simple. Let f be a differentiable function
for all x ∈ R. Pick a starting point, x0. Then we compute
x1 = x0 −
f(x0)
f ′(x0)
.
If f(x1) is not close enough to 0, the process is repeated as
xn+1 = xn −
f(xn)
f ′(xn)
until sufficiently precise value is reached. Read more about this here
2 Final Project part 1
Part 1 of final project is to create a script that uses Newton’s method to find a root of a polynomial. You can use
either MATLAB or Python and you can choose to do it numerically or symbolically. However, if you choose to use
one software, you will need to use the other one for part 2. Similarly, if you choose to do part 1 numerically, then
you will need to do part 2 symbolically. My recommendation is to use MATLAB and to do numerically. Here’s
what I expect from your script.
1. Start by asking the order, say n, of the polynomial we want to work with. If the input is not a positive
integer, then print ‘n must be a positive integer’ and ask for the input again. This must be repeated until an
acceptable value is provided.
2. Ask for the coefficients of the polynomial. For i < n, the prompt message should be something like ‘Enter the
coefficient for i:’. For n, the prompt message should be something like ‘Enter the last coefficient:’. If the last
coefficient is equal to 0, then print ‘The last coefficient must be nonzero.’ and ask for the input again. This
must be repeated until an acceptable value is provided.
3. Prompt a message asking for the starting point, x0.
4. Using the given polynomial and starting point, find the root using Newton’s method.
If you are doing numerically, estimate derivatives using ∆x = 10−6
If you are doing symbolically, calculate the exact values of derivatives.
5. The procedure can stop if f(xm) < 10
−14.
6. If you iterated for more than 106 times or if f(xm) > 10
10 or f ′(xm) < 10
−10, then stop the procedure and
print something like ‘Couldn’t find a root.’.
7. If f(xm) > 10
−14 and f ′(xm) = 0, then stop the procedure and print something like ‘The method failed. Pick
another starting point.’.
8. If you found xm as desired, then print ‘The solution to the given polynomial is xm.’. (xm needs to be the
actual value)
Extra credit: Create a plot that illustrates what you did to find the solution.
1
https:
en.wikipedia.org/wiki/Newton%27s_method
    Newton's method
    Final Project part 1

1 Taylor Series
A Taylor series is a representation of a function as an infinite sum of polynomials. Given a differentiable function
f(x), the Taylor series centered at c is
∞∑
n=0
f (n)(c)
n!
(x− c)n.
As we learned before, a Taylor series representation is a great way to estimate a function. Of course, since we
only want to estimate, we will deal with finite Taylor polynomial rather than a Taylor series. m-th degree Taylo
polynomial of a function f(x) centered c is
m∑
n=0
f (n)(c)
n!
(x− c)n.
2 Final Project part 2
In this project, you will write a script that will plot both a function and m-th degree Taylor polynomial of the
function. If you used MATLAB(or Python) for part 1, then you must use Python(or MATLAB). Similarly, if you
did part 1 numerically(or symbolically), then you must do part 2 symbolically(or numerically)
1. The script must take a function(f), degree of a Taylor polynomial(m) and the center(c). If not specified take
m = 10 and c = 0.
2. If m is not a positive integer, then print ‘n needs to be a positive integer.’
3. If c is not a real number, then print ‘c needs to be a real number.’
4. Create a figure that prints both the function f and the Taylor polynomial. Make sure x-axis displays from
c− 10 to c + 10. Also, two lines must be different color and include a legend to show which one is which.
5. If you are doing this numerically, estimate the derivatives using ∆x = 10−6. If you are doing this symbolically,
calculate the exact values using diff command.
6. Make sure graphs look smooth.
Here are some tips!
1. If you are using Python, then you can import math package and use math.factorial(n) to calculate n!.
2. If you are doing symbolically, make sure you feed a symbol instead of a function. That is, you need to provide
sp.exp(x) as an argument rather than f(x) which is a function. (You could use a function as an argument
ut then you will need to change that to symbol.)
1
    Taylor Series
    Final Project part 2

1 Final project part 3
Write a script that defines two new classes, circle and rectangle. Class circle should satisfy the followings.
1. Take (x, y) coordinate of the center as arguments. (0, 0) should be the default value.
2. Take the radius of the circle as an argument. r = 1 should be the default value.
3. Create a method that calculates the area of the circle.
4. Create a method that calculates the circumference of the circle.
5. Create a method that determines whether or not the given point (x, y) is inside the circle. Print ‘Given point
is in the circle.’ or ‘Given point is not in the circle.’ as result.
6. Extra Credit(5 pts): Create a method that graphs the given circle.
Class rectangle should satisfy the followings.
1. Take (x, y) coordinate of the center as arguments. (0, 0) should be the default value.
2. Take the width(x direction) and height(y direction) as arguments. 1 should be the default value for both.
3. Create a method that determines whether or not the rectangle is a square. Print ‘It is a square.’ or ‘It is not
a square.’ as result.
4. Create a method that calculates the area of the rectangle.
5. Create a method that calculates the perimeter of the rectangle.
6. Create a method that determines whether or not the given point (x, y) is inside the rectangle. Print ‘Given
point is in the rectnagle.’ or ‘Given point is no in the rectangle.’ as result.
7. Extra Credit(5 pts): Create a method that graphs the given rectangle.
1
    Final project part 3

Project 2
September 13, 2021
In mathematics, there are many simple hard problems; problems that look simple but are amazingly hard.
Collatz conjecture is one of these problems. So what is Collatz conjecture? Let’s take any positive integer m. If m
is even, then we divide it by 2, m1 =
m
2 . If m is odd, then we multiply it by 3 and add 1, m1 = 3m + 1. We will
epeat this process with m1 to create m2, m3, · · · . The conjecture claims that if we will eventually end up with 1.
Let’s look at an example.
1. Starting value: m = 3.
2. m1 = 3 ∗ 3 + 1 = 10.
3. m2 =
10
2 = 5.
4. m3 = 5 ∗ 3 + 1 = 16.
5. m4 =
16
2 = 8.
6. m5 =
8
2 = 4.
7. m6 =
4
2 = 2.
8. m7 =
2
2 = 1.
So it takes 7 steps to get 1 if you start from 3. So far, we tested the conjecture for starting values up to 268 and all
starting values eventually end up with 1. Now, mathematicians have little to no clue how to show this conjecture is
true for all numbers (or show that the conjecture is false). What’s even more interesting is the size of the starting
value does not directly tell us the number of total steps needed. For example, if you start with 32, it only takes 5
steps to reach 1. However, if you start with 27, it takes 111 steps to reach 1. In this project, we will investigate
Collatz conjecture using MATLAB.
1. Write a script that will take the starting value as an input and test whether it reaches 1.
(a) If it takes more than 100,000 steps, the script should stop and print It takes more than 100,000 steps to
test the conjecture.
(b) If there exists 1 < i < j < 100, 000 such that mi = mj , the script should stop and print Collatz conjecture
is false and m is the counter example! (m should be the starting value).
(c) If it reaches 1 in less than 100,000 steps, the script should stop and print Collatz conjecture is true fo
m and it takes n many steps to reach 1. (m should be the starting value and n should be the minimum
number of steps needed to reach 1 from m). Also, create a line plot of cu
ent step(i) vs. cu
ent
number(mi). The figure should have markers and appropriate title, x-axis and y-axis names.
2. Write a script that will take a number, k, as an initial input then find the first number that will take more
than or equal to k many steps to reach 1. For example, if k = 111, then the answer should be 27.
(a) If the starting value needs to be bigger than 100,000, the script should stop and print All the starting
values up to 100,000 take less than k steps to reach 1 (k should be the step size).
(b) If there is an answer, m, smaller than 100,000, the script should stop and print m is the first starting
value that takes at least k steps to reach 1 (m should be the answer and k should be the step size). Also,
create a bar graph of step size(k) vs. Number of starting values needing k steps for all starting values up
to m. The bar graph should have appropriate title, x-axis and y-axis names.
3. Once you are done, submit both scripts to Blackboard dropbox.
1
Answered 8 days After Oct 23, 2021

Solution

Mathews answered on Nov 01 2021
120 Votes
greynodes/circle.m
classdef circle % classs name is defined as circle
properties % properties are saved in the file
xcenter=0;
ycenter=0;
radius=1;
end

methods
function Area = getArea(newcircle)% function used to create the area of the circle
%RECTANGLE Construct an instance of this class
% Detailed explanation goes here
Area=(newcircle.radius*3.14*newcircle.radius);
end

function perimeter = getperimeter(newcircle)% function used to create the perimeter of the circle
perimeter= 2*3.14*newcircle.radius;

function newcircle =circle(Radius,Xcenter,Ycenter)
newcircle.radius = Radius
newcircle.xcenter = Xcenter;
newcirclele.ycenter = Ycenter;

end
end
end
end
%Run the command and after running the command type
%getArea(circle)
% This will yield in pproducing the circle area
%getperimeter(circle)
% This will yield in getting the perimeter of circle
greynodes/finalprojectpart1a144pxw5 .m
close all
clear all
clc
n=input('Enter the order of polynomial');
while n<1
n=input('Enter the order of polynomial positive integer');
end
p=zeros(n,1);
for j=1:n
if(j i=input('Enter the co
esponding coefficients ');
p(j)=i;
elseif(j==n)
i=input('Enter the last coefficients ');
p(j)=i;
if(p==0)
i=input('Last coefficients should be non zero')
end
end
end
pp=flip(p);
x0=input('input the starting number')
f=0;
fd=0;
i=1;
n1=n;
tol=10000;

%while(tol
while(i ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here