CS61A Lecture 06: Newton's Method

3 Pages
Unlock Document

University of California - Berkeley
Computer Science
De Nero

Lambda Expressions lambda x: x * x == Square(x) *Not common, cannot contain statements Def square = lambda x : x * x -- > return body ^ formal parameters square = lambda x: x*x VS def square(x) Both create function with same domain, range, behavior Both function have as parent the environment in which defined Both bind function to name square Only def gives statement intrinsic name Function Currying def curry2(f): def g(x): def h(y): return f(x, y) return h return g **Same as make_adder Currying: transform a multiargument function into a single argument, higher-order function Newton's Method Quickly find accurate approximations to zeroes of differentiable functions Zero = f(x) = 0 Application: method for compute square root, cube root Positive zero of f(x) = x^2 - a, = sqrt(a) (x^2 = a) Given a function f and initial guess x: Repeatedly improve X 1. Compute value of f at guess: f(x) 2. Compute derivative of f at guess: f'(x) 3. Update guess x to: x - f(x) / f'(x) Finish when f(x) = 0 Using Newton Method Find sqrt ( 2 ) f = lambda x: x*x - 2 --> f(x) = x^2 - 2 df = lambda x: 2x --> f'(
More Less

Related notes for COMPSCI 61A

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.