Discrete Mathematics (Statement) - discrete-mathematics

1) x^2 + x + 1 = 0 , x is a real number.
Answer: Is a statement.
2) x^2 + x + 1 = 0 , x is complex number.
Answer: Is not a statement.
Why the question no.2 is not a statment ?

To expand on Jiale's answer:
A statement is a statement which has a definite truth value.
1) x^2 + x + 1 = 0 , x is a real number.
This can be considered a statement because it is always false regardless of how x is chosen. This is because there is no real number which satisfies this equation. Therefore, it is guaranteed to have a definite truth value: false.
2) x^2 + x + 1 = 0 , x is complex number.
This cannot be considered a statement because it is true for some complex numbers x, and false for others. The truth value of this expression is only definite once x is specified. Therefore, it is not a statement.

Reason: A Statement is a declarative statement that is either true or false but not both.

Related

how to prove that the hash function h(x) = x² mod 4 yields only to 0 and 1

How can I prove that the hash function h(x) = x² mod 4 yields only to {0, 1}, with x as an element of the natural numbers?
Let's first cover the even numbers, 2n (where n is a natural number):
(2n)2
= (2n)(2n)
= (2)(n)(2)(n)
= (2)(2)(n)(n)
= 4n2
= 4(n2)
That's an exact multiple of four so the remainder when dividing by four will always be zero.
Now let's cover the odd numbers, 2n + 1:
(2n + 1)2
= (2n + 1)(2n + 1)
= (2n)(2n) + (2n)(1) + (1)(2n) + (1)(1)
= 4n2 + 2n + 2n + 1
= 4n2 + 4n + 1
= 4(n2 + n) + 1
That's exactly one more than a multiple of four hence the remainder when dividing by four will always be one.
Now, let's look at any natural numbers that are neither even nor odd.
Wait a minute, there aren't any. I guess that means we're done :-)
And, before anyone points out that some languages may give a negative remainder when the arguments are negative, that doesn't actually apply here since the square of a natural number can never be negative.

What does y==x mean in MATLAB?

I came across some MATLAB code online and it was running just fine, but I couldn't understand the meaning of (y == x) where y is a column matrix and x is an integer.
someFunction(y == x);
Is it some kind of comparing or setting some value of y?
The instruction
y == x
checks which values in the array y (if any) are equals to the scalar x and returns a logical array of the size of y in which 1 is set in the location where the value of the element of y is equal to the value of x and 0 in the other case.
It ha to be assumed tha also the array y is of integer type, otherwise the comparison does not have sense.
Therefore, the function someFunction seems accepting as input a logical array.
As an example, with
y = [10 2 10 7 1 3 6 10 10 2]
and
x=10
the code
(y == x)
returns the logical array:
1 0 1 0 0 0 0 1 1 0
This will be the input someFunction function.
Hope this helps,
QWapla'

differences between x = y and x = y == 1

Suppose we have logical image y and we want to make a copy of it. What is differences between the following statements:
x = y;
x = y==1;
x = y is an assignment. It sets the variable x to the value currently contained in variable y.
x==y is a logical operator asking "Is x equal to y"?
The statement x=y==1 sets all parts of x to true where the corresponding value of y is equal to 1.
The difference between the two statements you pose is thus that in the first statement, x=y, x becomes an exact copy of y. In the second statement however, x becomes a logical matrix with boolean values. 1 where y contains a 1 and 0 where y contains anything but 1.
In your specific case, where y already is a logical matrix (thus containing only 1 and 0) both statements are thus equivalent as per the above and then the first statement will be faster as the equality check is redundant and thus adds unnecessary overhead.

Is 1 + 1 == 2 always true in Matlab?

As this example suggests:
0.1 + 0.1 + 0.1 == 0.3
gives the surprising result of false due to precision issues when storing 0.1.
However,
1 + 1 + 1 == 3
evaluates to true as expected. Note that there is still the issue of comparison of floating numbers here. As pointed out in the comments, the default numeric data type is double unless specified otherwise.
My question is, if a + b + c + ...= T, and a, b, c, ... , T are all integers, is the evaluated value of
a + b + c + ... == T
always true?
What other ways are there to relax the condition of a, b, c, ... , T being integers and still maintain the truth of the above statement?
As helpfully pointed out in one answer, any sort of overflow encountered at any point of the evaluation will cause this to evaluate to false:
A = realmax('double')
A - A + A == A % evaluates to true
A + A - A == A % evaluates to false
Thus, for the purposes of my original question, assume that no overflow problems at encountered at any stage necessary to evaluate the expression.
If integers are represented using fixed-sized data types, then there is a limit to how large (in magnitude) a number can be represented. Thus, if a calculation would go over that limit (a condition known as overflow), the result would not be correct.
If you think about how integers are represented in floating point notation, as long as there is no representation error there will be no problem with equality comparison. For "small" integers it is never an issue, because you have plenty of bits for the mantissa and they can be represented exactly. If you try adding very (really) large integers, then issues may arise:
>> 2^50 == 2^50+1
ans =
0
While:
>> 2^53 == 2^53+1
ans =
1
This is the overflow that Scott Hunter is talking about. Look for IEEE Standard 754 to learn more about the representation of floating point numbers.

Stability (Numerical analysis)

I'm trying to find the max machine number x that satisfies the following equation: x+a=a, where a is a given integer. (I'm not allowed to use eps.)
Here's my code (which is not really working):
function [] = Largest_x()
a=2184;
x=0.0000000001
while (x+a)~=a
x=2*x;
end
fprintf('The biggest value of x in order that x+a=a \n (where a is equal to %g) is : %g \n',a,x);
end
Any help would be much appreciated.
The answer is eps(a)/2.
eps is the difference to the next floating point number, so if you add half or less than that to a float, it won't change. For example:
100+eps(100)/2==100
ans =
1
%# divide by less than two
100+eps(100)/1.9==100
ans =
0
%# what is that number x?
eps(100)/2
ans =
7.1054e-15
If you don't want to rely on eps, you can calculate the number as
2^(-53+floor(log2(a)))
You're small algorithm is certainly not correct. The only conditions where A = X + A are when X is equal to 0. By default matlab data types are doubles with 64 bits.
Lets pretend that matlab were instead using 8 bit integers. The only way to satisfy the equation A = X + A is for X to have the binary representation of [0 0 0 0 0 0 0 0]. So any number between 1 and 0 would work as decimal points are truncated from integers. So again if you were using integers A = A + X would resolve to true if you were to set the value of X to any value between [0,1). However this value is meaningless because X would not take on this value but rather it would take on the value of 0.
It sounds like you are trying to find the resolution of matlab data types. See this: http://www.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html
The correct answer is that, provided by Jonas: 0.5 * eps(a)
Here is an alternative for the empirical and approximate solution:
>> a = 2184;
>> e = 2 .^ (-100 : 100); % logarithmic scale
>> idx = find(a + e == a, 1, 'last')
idx =
59
>> e(idx)
ans =
2.2737e-013