answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
patriot [66]
2 years ago
7

Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of

the square root should be passed as a second argument to the function.) An example of the program
Computers and Technology
1 answer:
PIT_PIT [208]2 years ago
3 0

Answer:

import math

tolerance=0.00001

approximation=1.0

x = float(input("Enter a positive number: "))

def newton(number,approximation):

   approximation=(approximation+number/approximation)/2

   difference_value =abs(number-approximation**2)

   if difference_value<= tolerance:

       return approximation

   else:

       return newton(number,approximation)

print("The approximation of program = ", newton(x, approximation))

print("The approximation of Python = ", math.sqrt(x))

Explanation:    

  • Create a recursive function called newton that calls itself again and again to approximate square root for the newton technique.
  • Apply the formulas to find the estimate value  and the difference value .
  • Check whether the difference_value is less than the tolerance value  and then return the value of approximation  else make a recursive call to the newton function by passing the  user input and the new approximation value .
  • Finally display all the results using the print statement.
You might be interested in
Given an n-element array X, algorithm D calls algorithm E on each element X[i]. Algorithm E runs in O(i) time when it is called
krek1111 [17]

Answer:

O(n^2)

Explanation:

The number of elements in the array X is proportional to the algorithm E runs time:

For one element (i=1) -> O(1)

For two elements (i=2) -> O(2)

.

.

.

For n elements (i=n) -> O(n)

If the array has n elements the algorithm D will call the algorithm E n times, so we have a maximum time of n times n, therefore the worst-case running time of D is O(n^2)  

5 0
2 years ago
Multiple boolean expressions can be combined by using a logical operator to create ________ expressions.
Licemer1 [7]
<span>Boolean expressions can be combined by using a logical operator to create compound expressions. A boolean expression is an expression that takes into account and evaluates specific data, which is in the form of true and/or false. A compound expression is merely a statement of expressions.</span>
8 0
2 years ago
HELP PLEASE ASAP brainliest to accurate
Svet_ta [14]
A patent law

Patent laws deal with new inventions and relays to the owner’s exclusive right to the claimed invention. It is a right that should be granted by the government to an inventor, to exclude others from using, making, importing, or selling an invention. In this case, Jenna's secret, unique recipe is her patent.


3 0
2 years ago
Read 2 more answers
Show how to define a view tot_credits (year, num_credits), giving the total number of credits taken by students in each year
andreev551 [17]

Hi! I'm a Digital Marketer Intern at hotels.ng and I have a moderate knowledge on programming.

First, your  question is not very explanatory. The term "view" is often used in back-end web development. A view is simply a Python function that takes a Web request and returns a Web response.

But I'm not sure this is what you want, so I'll just go ahead and write a python function involving class to return the total number of credits taken by a student.

I'll answer this question using Python.

class student(object):  

    credits = None

    year = None

    def num_credits(self):


       #get credit value

       self.credits = input("Enter the total number of credits: "  )


       pass

    def getYear(self):

        self.year = input("Enter current year: ")

        pass

    def tot_credits(self):

          TotalCredits = tempTotalCredits + self.num_credits

           print "Your  total credits are :"+" "+str(TotalCredits)




3 0
2 years ago
Value is always _____________ aligned in a cell. ​
Nadya [2.5K]

Answer:

Right

Explanation:

7 0
1 year ago
Other questions:
  • Suppose the algorithms used to implement the operations at layer k is changed. how does this impact services at layers k-1 and k
    10·1 answer
  • Write a program that can convert an integer between 0 and 15 into hex number (including 0 and 15). the user enters an integer fr
    15·1 answer
  • Splunk uses ________ to categorize the type of data being indexed..
    11·2 answers
  • When seeking information on the internet about a variety of subjects the most useful place to look would be?
    13·2 answers
  • Blender questions
    8·2 answers
  • Mara's presentation included essential information about the company's new safety procedures. She wanted to make
    13·2 answers
  • Some early computers protected the operating system by placing it in a memory partition that could not be modified by either the
    5·1 answer
  • Write a client program that writes a struct with a privateFIFO name (call it FIFO_XXXX, where XXXX is the pid that you got from
    11·1 answer
  • Given the plaintext {0F0E0D0C0B0A09080706050403020100} and the key {02020202020202020202020202020202}: a. Show the original cont
    11·1 answer
  • Exercise 3.6.9: 24 vs. "24"5 points
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!