Simplifying Boolean Algebra [closed] - boolean

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to prove that BC + !A!B + !A!C = ABC +!A
I have attempted using De Morgan laws, and substituting X for !A!B and Y for !A!C, however I made no headway in this.
I"ve alos tried gruopoing the A's like so, !A(!B+!C), however again I couldn't get anywhere. If anyone could point me in the right direction, help me solve, show me a tool that can do it, etc. I'd be grateful.

BC + !A!B + !A!C
= BC + !A(!B + !C) distributive law
= BC + !A!(BC) De Morgan's law
= (A + !A)BC + !A!(BC) identity and x OR !x = true
= A(BC) + !A(BC) + !A!(BC) distributive law
= ABC + !A((BC) + !(BC)) distributive law
= ABC + !A x OR !x = true and identity

Related

How to Check if Variable exists in Scala [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 8 months ago.
Improve this question
I want to check if a variable is already defined/exists in scala or not. Lets say a function called checkVar do this operation:
var x = 10
checkVar(x) -> returns boolean True
checkVar(y) -> returns boolean False
I am asking this question because I want to create a mechanism to define a variable if it doesn't exist.
Variables only exist at compile time so you can't dynamically create or delete variables at runtime. So both x and y must be defined at compile time or else the compiler will reject the code.
What you can do is use Option to indicate whether a variable has a value or not:
def checkVar(v: Option[Int]) = v.nonEmpty
var x = Some(10)
checkVar(x) // True
val y = None
checkVar(y) // False
x = None
checkVar(x) // False

how do i approach "h" parameter to zero in derivative? [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
I have a few problem with my derivative because it shows me an error when I approach Denominator to zero .
func derivativeOf(fn: (Double) -> Double, atX x: Double) -> Double {
let h -> 0
return (fn(x + h) - fn(x))/h
}
i know my syntax sucks but currently it is common in calculus and mathematical Differential.
You can't express "number approaching zero" as let h -> 0 - this is just an invalid syntax in Swift.
There's also no specific operator for "number approaching zero". But depending on what you need, you could for example express "smallest possible positive number", using Double.leastNonzeroMagnitude:
let h = Double.leastNonzeroMagnitude

How to compute the mean-square in Matlab? [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
I want to compute the square of mean-square for each element of l
l=[0.02817088, -0.74100320, -0.54062120, -0.24612808, 0.06945337, -0.58415690, -0.51238549,
-0.07862326, -0.42417337, -0.33482340, -0.21339753, -0.03890844, -0.59325371, 0.28154593,
-0.32133359,-0.13534792, 0.14060645, 0.32204972, 0.44438052, -0.21750973,-0.59107599,
-0.60809913]'
k= -0.2224834
sum(l-k)^2/22
I am not sure if sum(l-k)^2/22 is the sum of each (l[j]-k) for j=1,2,...,22?
ans = 2.4223e-14
I guess what you need might be
>> mean((l-k).^2)
ans = 0.10945
Data (You need ... for line continuation if you have data in different lines for l)
l=[0.02817088, -0.74100320, -0.54062120, -0.24612808, 0.06945337, -0.58415690, -0.51238549, ...
-0.07862326, -0.42417337, -0.33482340, -0.21339753, -0.03890844, -0.59325371, 0.28154593, ...
-0.32133359,-0.13534792, 0.14060645, 0.32204972, 0.44438052, -0.21750973,-0.59107599, ...
-0.60809913]'
k= -0.2224834

How to express the performance of loop & inner loop in big o notation? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
For below loop and inner loop to express the performance in big o notation is :
O(N squared) as its performance is proportional to the square of the size of the input data set.
var counter = 0
var counterval = 0;
for ((key, value) <- m2.par){
for ((key2, value2) <- m2.par){
counter = counter + 1;
println(counter)
}
println(counterval)
}
Is this correct ?
Yes, if you consider the size of m2 to be the input size and that increasing counter and printing it are both O(1) (which is a very reasonable assumption).

Check for MATLAB dataset consistency [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
In the case of matrices the following command works fine for me every time I want to make sure that its contents are REAL NUMBERS, but always BIGGER THAN ZERO and FINITE. But, it doesn't work for datasets.
ispositive = ( ~isnumeric(batch_data) ...
| ~all(isfinite(batch_data(:))) ...
| ~isreal(batch_data) ...
| ~(any(batch_data(:) <= 0)) );
if (ispositive)
end
Any idea on how to modify it?
ispositive = ( ~isnumeric(batch_data) ...
| ~all(isfinite(batch_data(:))) ...
| ~isreal(batch_data) ...
| ~(any(batch_data(:) <= 0)) );
This does NOT do what you say.
According to this statement the following are positive:
batch_data = Inf
batch_data = -Inf
batch_data = 'ralph'
batch_data = 1j;
batch_data = -1j;
Related to what you wrote, this works:
positive = all(isnumeric(batch_data(:)) ...
&& all(isfinite(batch_data(:))) ...
&& isreal(batch_data) ... % isreal breaks convention of is* functions
&& all(batch_data(:) > 0)) ;