This problem requires using R studio. This question is from Verzani (Problem 2.15) Can some write the code for the answer to the question below:
The negation operator ! is used with reverse Boolean values. For example:
A <- c(True, False, True, False)
!A
##[1] False True False False
One of De Morgan's laws in R code is ! (A & B) = !A | !B . Verify this with B <- c(False, True, False, True) and A as above.
R-code:
A <- c(TRUE, FALSE, TRUE, FALSE)
B <- c(FALSE, TRUE, FALSE, TRUE)
C=A&B
C
!C
!A
!B
D=!A | !B
D
Output:
> A <- c(TRUE, FALSE, TRUE, FALSE)
>
> B <- c(FALSE, TRUE, FALSE, TRUE)
>
> C=A&B
>
> C
[1] FALSE FALSE FALSE FALSE
>
> !C
[1] TRUE TRUE TRUE TRUE
>
> !A
[1] FALSE TRUE FALSE TRUE
>
> !B
[1] TRUE FALSE TRUE FALSE
>
> D=!A | !B
>
> D
[1] TRUE TRUE TRUE TRUE
Comment: Since !C=!(A & B) & D=!A | !B are same , this proves De Morgan's laws ! (A & B) = !A | !B .
Get Answers For Free
Most questions answered within 1 hours.