Logical Venn Diagrams [closed] - math

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I have this question :
Unfortunately, my book didn't provide definition and how to draw/read a logic venn diagram, i have to look at the internet but couldn't find any understandable explanation
From what i understand, the logics for the three diagrams are :
X AND NOT (Y OR Z)
NOT X AND (Y OR Z)
Y AND NOT (X OR Z)
Am i right ? Please correct me if i'm wrong
By the ways, does the question mean to combine all three diagrams with OR operation, like :
1 OR 2 OR 3
Any help is greatly appreciated !

I could not understand the question correctly. Here's the logic for the three Venn Diagrams:
1. Your logic for the first Venn Diagram is correct: X AND NOT (Y OR Z)
2. Your logic for the second Venn Diagram is slightly incorrect, if you look at the Venn Diagram: It is simply NOT (X) (Everything except X).
3. In this case as well, the logic is simply Y.
Now if we perform OR operation on these three:
(X AND NOT (Y OR Z)) + NOT(X) + Y
= X AND NOT(Y) AND NOT(Z) OR NOT(X) OR Y [By de Morgan's law]
which matches option c.
NOTE: Your second and third logics would have been correct if X, Y and Z were the only three regions in the diagram. However there is also a region outside all of them - bounded by the box. You might want to look up on the internet about basics of Venn Diagram, it's one of the easiest things to learn IMO!

Related

Coding a plot with functions [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
So I've probably referenced the entire internet trying to make this problem work, and haven't. However, I found stack overflow. Like I said I've been learning for not even 2 weeks yet.
So this is the problem
Let
f(x)=sqrt((x^3+3x^2+1)/(x^4+5x^3+7x+9))
(x ≥ 0)
(a) Draw a line graph of (x, f(x)) for 0 ≤ x ≤ 10 with increments of 0.01
(b) Find numerically the maximum value of f(x) and the maximizer x (report x to the
second decimal place. For instance, x = 1.23)
So I'm basically been saying x=x and y= the sqrt....., and then I write plot(x,y,type="l") and usually it just doesn't even work.
Also how do I do the increment part. I'm sorry for lack of explanation, but I have no idea what most of this means.
First thing to do would be to define the function:
equation <- function(x){
sqrt((x^3+3*x^2+1)/(x^4+5*x^3+7*x+9))
}
Then, define the values you want to apply the function to, and store them in vector input
input<-seq(0,10,0.01)
Apply the equation function to input, and store the values in vector results
results<-sapply(input,function)
Produce a line plot:
plot(input,results,type="l")
Print the value of x which maximises f(x)
maxx<-input[which.max(results)]
maxx
I would suggest a ggplot2 approach. First you have to create a random x variable and then compute y. I will add the code for that variables an the plot.
In the case of finding the maximum of f(x) you must know calculus or you can use a visual approach. Here the code:
library(ggplot2)
library(dplyr)
set.seed(123)
First we create a random variable x with the limits you mentioned:
#Data
x <- runif(100,0,10)
Now, we save the variable in a dataframe and compute y:
#Allocate data in a dataframe
df <- data.frame(x=x)
#Compute variable
df$y <- sqrt(((df$x^3)+3*((df$x)^2)+1)/((df$x^4)+5*(df$x)^3+7*(df$x)+9))
Finally, we plot:
#Plot
ggplot(df,aes(x=x,y=y))+
geom_point()+
scale_x_continuous(limits = c(0,10))
Output:
Values for x are randomly generated, if you have real values for x you should use those values.

Find x and y coordinates where a perpendicular point crosses a straight line [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
This is a follow-up question to this question.
Taking the following image as an example:
What I know:
x and y coordinates of points D, E, and P.
Therefore, I also know slope and intercept of D-E line
What I want to know:
x and y coordinates of point Q. (This is the point which crosses the D-E line).
Notation P=[px,py], D=[dx,dy], E=[ex,ey], Q=[qx,qy]
First:
R=P-D=[px-dx, py-dy]=[rx,ry]
K=E-D=[ex-dx, ey-dy]=[kx, ky]
Then
z=dot(R,K)/dot(K,K)=(rx*kx+ry*ky) / (kx*kx+ky*ky)
Finally
Q=D+z*K=[dx+z*kx, dy+z*ky]
The R is vector which start on point D and ends on point K, the K is vector which start on point D and ends on point E. Using this we made scalar projection to calculate result Q. More info about concept here

Getting theta of Line Equation [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
Please forgive my lack of knowledge, which i think it's one of those basic formula related to Trigonometry.
Let's look at visual example:
I have 5 lines, with their line equation (let's say they have zero offset ok)
how can i calculate the Theta of each line equation make (in Pi)?
also I have seen this:
Are they generated from Theta of line equations? or it's another theory which help to find the theta?
much appreciate your time and effort
For equation
y = k * x
tg(Theta) = k
and
Theta = Arctg(k) //arctangent function
General line equation
A * x + B * y + C = 0
(It is more general than y=ax+b and includes cases of vertical and horizontal lines)
Theta = atan2(A, B)
(function atan2 or ArcTan2 exists in math libraries of many programming languages)

Creating a Polygon in r -- without connected vertices [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am trying to create a polygon out of this line graph -- is it possible to do without having connected vertices? If so, how do I change the polygon code to do so?
I'm assuming the reason you what to create a polygon is to shade or color within its boundaries. If I'm wrong about that assumption then you really should put more effort into making your questions explicit. The trick is to connect at the ends of those lines by putting them both in one vectors, at the same time as reversing the X and Y for one of the series.
x <- 1:100
y1=6 + rnorm(100)
y2 = rnorm(100)
plot(x, y1, ylim=c(-3,10) )
?polygon
polygon(x= c( x, rev(x) ), y=c(y1,rev(y2) ), col="red")

plotting 3d graph by stacking 2d contour plots in R [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I have got two different variables x and y that are both functions of variable z. I have multiple contour plots of x vs y at different z values. What I want to do is put these graph slices together along z axis to get a 3D-ish graph.
I searched for packages that lets me do this in R and all I could find was contourrslice in Matlab. Contourslice is exactly what I want but in R.
Is there a package/ function in R like contourslice or any other ways I could go about doing this?
EDIT: Here's a dummy data. For different values of z the heat map changes. I have these several 2D plots, for values of z from -1 to 15. I want to put these 2D plots together along z axis to get a 3D ish figure to see how the red area is displaced.
#Create range of values for x and y
x<- c(11,25)
y<- c(1,5)
length<-10
x_ran <- as.matrix(seq(x[1],x[2], len=length))
y_ran <- as.matrix(seq(y[1],y[2], len=length))
#initialise matrix
x_mat<- x_ran[,rep(1,length)]
y_mat<- t(y_ran[,rep(1,length)])
#Third variable z
z<- -1
#z<- 1
#z<-2
#z<-3
#R and C, funcition of z
R <- x_mat*z
C<-z-y_mat
toget<- R/C
image(toget, xlab="R", ylab="C")

Resources