Question

In: Advanced Math

1. Let g(s) = √ s. Find a simple function f so that f(g(s)) = 0....

1. Let g(s) = √ s. Find a simple function f so that f(g(s)) = 0. Hint: see Methods of computing square roots on Wikipedia. Use Newton’s method to estimate √ 2. Start with 3 different (and interesting) initial values of your choice and report the number of iterations it takes to obtain an accuracy of at least 4 digits.

In python.

Solutions

Expert Solution

#Python code

import math
def func(x,S):
return (math.pow(x,2)-S)
def diff_func(x,S):
return (2*x)
S= int(input('Enter the number for which square needed to be found: '))
x= []
x.append(int(input('Enter initial approximation value: ')))
i=0
count=0
while(True):
f= func(x[i],S)
df= diff_func(x[i],S)
x.append(round(x[i]-(f/df),4))
if x[i+1]==x[i]:
break
count+=1
i+=1
print('Square root of ' + str(S) + ' is ' + str(x[i]))
print('Total number of iterations that took to achieve the accuracy of 4 digits is ' + str(count))

Output 1:

Enter the number for which square needed to be found: 24   

Enter initial approximation value: 5   

Square root of 24 is 4.8989                                                                                                                                   

Total number of iterations that took to achieve the accuracy of 4 digits is 2

Output 2:

Enter the number for which square needed to be found: 73

Enter initial approximation value: 9                                                                                                                         

Square root of 73 is 8.5440

Total number of iterations that took to achieve the accuracy of 4 digits is 2

Output 3:

Enter the number for which square needed to be found: 141   

Enter initial approximation value: 11                                                                                                                        

Square root of 141 is 11.8743                                                                                                                                

Total number of iterations that took to achieve the accuracy of 4 digits is 3


Related Solutions

Let f(x, y) be a function such that f(0, 0) = 1, f(0, 1) = 2,...
Let f(x, y) be a function such that f(0, 0) = 1, f(0, 1) = 2, f(1, 0) = 3, f(1, 1) = 5, f(2, 0) = 5, f(2, 1) = 10. Determine the Lagrange interpolation F(x, y) that interpolates the above data. Use Lagrangian bi-variate interpolation to solve this and also show the working steps.
Let f: [0 1] → R be a function of the class c ^ 2 that...
Let f: [0 1] → R be a function of the class c ^ 2 that satisfies the differential equation f '' (x) = e^xf(x) for all x in (0,1). Show that if x0 is in (0,1) then f can not have a positive local maximum at x0 and can not have a negative local minimum at x0. If f (0) = f (1) = 0, prove that f = 0
If f(x) = exg(x), where g(0) = 3 and g'(0) = 4, find f '(0).
If \(f(x)=e^{x} g(x),\) where \(g(0)=3\) and \(g(0)=4,\) find \(f(0)\)
Let f : R → S and g : S → T be ring homomorphisms. (a)...
Let f : R → S and g : S → T be ring homomorphisms. (a) Prove that g ◦ f : R → T is also a ring homomorphism. (b) If f and g are isomorphisms, prove that g ◦ f is also an isomorphism.
Let f be a differentiable function on the interval [0, 2π] with derivative f' . Show...
Let f be a differentiable function on the interval [0, 2π] with derivative f' . Show that there exists a point c ∈ (0, 2π) such that cos(c)f(c) + sin(c)f'(c) = 2 sin(c).
a) Let S ⊂ R, assuming that f : S → R is a continuous function,...
a) Let S ⊂ R, assuming that f : S → R is a continuous function, if the image set {f(x); x ∈ S} is unbounded prove that S is unbounded. b) Let f : [0, 100] → R be a continuous function such that f(0) = f(2), f(98) = f(100) and the function g(x) := f(x+ 1)−f(x) is equal to zero in at most two points of the interval [0, 100]. Prove that (f(50) − f(49))(f(25) − f(24)) >...
Let function F(n, m) outputs n if m = 0 and F(n, m − 1) +...
Let function F(n, m) outputs n if m = 0 and F(n, m − 1) + 1 otherwise. 1. Evaluate F(10, 6). 2. Write a recursion of the running time and solve it . 3. What does F(n, m) compute? Express it in terms of n and m.
Let g be the function defined by g(x) = x(x + 1). Find g(x + h)...
Let g be the function defined by g(x) = x(x + 1). Find g(x + h) − g(x − h).
1.) Answer the following programs a.) Let f be the following function: int f(char *s, char...
1.) Answer the following programs a.) Let f be the following function: int f(char *s, char *t) {     char *p1, *p2;     for(p1 = s, p2 = t; *p1 != '\0'&& *p2 != '\0'; p1++, p2++){               if (*p1 == *p2) break;     }     return p1 -s; } What is the return value of f(“accd”, “dacd”)? b.) What will be the output of the below program? #include <stdio.h> int main()   {    char x[]="ProgramDesign", y[]="ProgramDesign";   if(x==y){   printf("Strings are...
Find the Laplace transforms: F(s)=L{f(t)} of the function f(t)=(8−t)(u(t−2)−u(t−5)), for s≠0. F(s)=L{f(t)}=
Find the Laplace transforms: F(s)=L{f(t)} of the function f(t)=(8−t)(u(t−2)−u(t−5)), for s≠0. F(s)=L{f(t)}=
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT