Class Notes
(808,549)

United States
(313,136)

Computer Science
(355)

COMPSCI 61A
(130)

De Nero
(43)

Lecture

# CS61A Lecture 06: Newton's Method

Unlock Document

University of California - Berkeley

Computer Science

COMPSCI 61A

De Nero

Fall

Description

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