COMPSCI 61A Lecture Notes - Currying, Cube Root

55 views3 pages
24 Oct 2013
School
Professor
zogo39484755 and 6 others unlocked
COMPSCI 61A Full Course Notes
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents

Document Summary

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. Function currying def curry2(f): def g(x): def h(y): return f(x, y) return h return g. Currying: transform a multiargument function into a single argument, higher-order function. Quickly find accurate approximations to zeroes of differentiable functions. 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: compute value of f at guess: f(x, compute derivative of f at guess: f"(x, update guess x to: x - f(x) / f"(x) Find sqrt ( 2 ) f = lambda x: x*x - 2 --> f(x) = x^2 - 2 df = lambda x: 2x --> f"(x) = 2x.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents