Upload
dd
View
17
Download
1
Embed Size (px)
Citation preview
# 1
Nested FunctionsNested Functions
How do we evaluate a complex formula?
What are DeMorgan’s Laws?
CS 105 Spring 2011
# 2
Grade Example
• Suppose there is 2% extra credit (column AK)
• Solution 1: create column AN for “Points + EC”
Then use• Solution 2:
CS 105 Spring 2011
Y
Y
Y=IF(AK2=“Y”,AI2*102%,AI2)
=VLOOKUP(AN2,AL2:AM12,TRUE)
=VLOOKUP( ,AL2:AM12,TRUE)IF(AK2=“Y”,AI2*102%,AI2)
# 3
• In order to evaluate a complex formula like
start by evaluating the inner parts
• The overall formula can be evaluated once the values of the inner sub-expressions are known
• A more complex example:
IF(ISERROR(VLOOKUP(value,range,col)),”No”,”Yes”)
CS 105 Spring 2011
Nested Functions
=VLOOKUP(IF(AK2=“Y”,AI2*102%,AI2),AL2:AM12,TRUE)
123
# 4
• Consider the following formulas:a) NOT(AND(X, Y))b) AND(NOT(X), NOT(Y))c) NOT(OR(X, Y))d) OR(NOT(X), NOT(Y))
• The formulas (a) and (d) are equivalent, and so are formulas (b) and (c)
• We can verify this with truth tables:
CS 105 Spring 2011
DeMorgan’s Laws
X Y AND(X,Y) NOT(AND(X,Y))
NOT(X) NOT(Y)
OR(NOT(X), NOT(Y))
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0
# 5CS 105 Spring 2011
Example: College AdmissionsExample: College Admissions• A college grants admissions based on three
criteria: SAT score (S), Letter score (L), and References (R)
• Which of these formulas is correct?
S L R Decision
1300 8.5 8.25 Strong accept
1200 8.0 7.80 Accept
1200 7.5 7.00 Reject
… ELSE … Manual
AND AND
AND AND
OR OR
IF(AND(S>=1300,L>=8.5,R>=8.25), "Strong accept",
IF(AND(S>=1200, L>=8, R>=7.8), "Accept",
IF(OR(S<1200, L<7.5, R<7), "Reject", "Manual")))
IF(OR(S<1200,L<7.5,R<7), "Reject",
IF(OR(L<8,R<7.8),"Manual",
IF(OR(S<1300,L<8.5,R<8.25),"Accept",
"Strong accept")))
# 6
• How do we evaluate a complex formula?
• What are DeMorgan’s Laws?
CS 105 Spring 2011
Testing Your Knowledge