Can someone explain me this boolean algebra equation - boolean

Can someone explain me this boolean algebra equation, using the table method and telling me explanation?
xy->z
I know the boolean logical operator "->", but what does xy mean? Is this only x, only y, or is it a mistake in the following equation?

xy is the logical AND of x and y. In your notation the 'v' symbol is used as logical OR. Usually '+' is used as OR as well.
Thus the left side of your equation reads "(x and y) or ([not x] implies [y and z])"

Related

Piecewise linear optimisation using matlab

I want to solve the following optimisation problem, whose objective function is independent of x:
minimise t
subject to a_i*x+b_i<=t
over x for all i from 1 to n=100
This problem arised from if I rewrite a piecewise linear optimisation problem to a linear optimisation problem.
Question:
How can I implement this in the matlab using linprog. In linprog I am asked to insert the objective function f as a matrix multiplying with x. Is it possible to have a objective function independent of x? If not, how am I going to implement this?
P.S: I don't know why Mathjax is not working here, I have been looking for how to ask questions with Math formula, but I was not successful. Therefore any correction is welcomed.
Edit:Here is the official document from Matlab for linprog. In it it is stated that the minimalising function has the shape of f^Tx. My problem is just that my minimalising function doesn't take such shape and is in the absence of x. How can I implement this in the Matlab?
You need to reformulate your problem into standard LP, i.e. find the nominal f, A and b as required by MATLAB's function linprog.
Here is the reformulation. From your question it seems x and t are two scalars.
Assume the given a_i's and b_i's are stored in column vectors a and b respectively, then your original problem:
min t, s.t. a * x + b <= t * ones(n,1)
is equivalent to:
min [0; 1]' * [x; t], s.t. [a, ones(n,1)] * [x; t] <= -b.
Thus, just use linprog([0; 1], [a, ones(n,1)], -b), and the solution is [x; t].

applying the same solver for complex matrix

Let assume an equation A x = b, where A is a real n x n matrix, b is a real valued vector of length n and x is the solution vector of this linear system.
We can find the solution of x by finding the inverse of A.
B= inv(A)
And therefore
x =A^{-1}b.
x= B*b
Can I apply the same solver if A and b are complex?
EDIT: I'm looking for explanation why it should work. Thanks :)
You can do that. Better in Matlab would be x = A\b. That will usually get the answer faster and more accurately.
In short yes, it works for any matrices irrespective of the field. (Well, at least real or complex field works.)
I think your question is whether B exists or not. It does as long as the determinant of B is non-zero. Vice versa.

Extract coefficients from symbolic expression

Let
syms h
g=exp(h)+h*exp(h)+h^2
so, the coefficients of g in respect to his given by the function coeffs:
coeffs(g,h)
and it returns:
[exp(h),exp(h),1]
It's like this function deals with the symbolic expression like a polynomial in h.
The problem is that this function doesnt return the zero coefficients, so if I have an
g=h*exp(h)+h^2
the function returns only:
[exp(h), 1].
But what I need is:
[0,exp(h), 1]
So, what can I do here?
I went to a lot of topics on SO and the solution is:
syms h
g=h*exp(h)+h^2
m = eval(feval(symengine,'coeff',g,h,'All'));
I hate to be one of those posters that lectures, but this is listed right in the Matlab help (help coeff) or online
coeffs(g,h, 'All')

How to Solve Equation Involving Subject of Formular In Matlab

I have an expression that I want to evaluate in MATLAB. This is a part of automatic control computation and each time I need to compute a theta(t) value which has a relationship as shown below:
My objective is to evaluate the left-hand side expression in the red box against row-wise equivalent right-side and obtain the actual value for t.
I will appreciate any help.
Assuming the Transformation Matrix is represented by T, therefore:
x = T(1,4)==V(1);
y = T(2,4)==V(2);
z = T(3,4)==V(3);
Apply linear equation solver: a=solve(x,t).
To obtain the actual value of t, eval(a).

Matlab: Error using ==> mpower

I'm trying to use fsolve in matlab to solve a system of nonlinear equations numerically. Here is a test sample of my program, k1 and R are parameters and x0 is the start point.
function y=f(k1, R, x0)
pair=fsolve(#system,x0);
y=pair(1);
function r=system(v)
int1=#(x) exp(k1*x);
int2=#(x) exp(k1*x^2)/(x^4);
r(1)=exp(v(1))*quadl(int1,0,v(1));
r(2)=exp(k1*v(2))*quadl(int2,v(1),20)*k1*R;
end
end
The strange thing is when I run this program, matlab keeps telling me that I should use .^ instead of ^ in int2=#(x) exp(k1*x^2)/(x^4). I am confused because the x in that function handle is supposed to be a scalar when it is used by quadl. Why should I have to use .^ in this case?
Also I see that a lot of the examples provided in online documentations also use .^ even though they are clearly taking power of a scalar, as in here. Can anybody help explain why?
Thanks in advance.
in the function int2 you have used matrix power (^) where you should use element-wise power (.^). Also, you have used matrix right division (/) where you should use element-wise division (./). This is needed, since quadl (and friends) will evaluate the integrand int2 for a whole array of x's at a time for reasons of efficiency.
So, use this:
function y = f(k1, R, x0)
pair = fsolve(#system,x0);
y = pair(1);
function r = system(v)
int1 = #(x) exp(k1*x);
int2 = #(x) exp(k1*x.^2)./(x.^4);
r(1) = exp( v(1)) * quadl(int1,0,v(1));
r(2) = exp(k1*v(2)) * k1*R*quadl(int2,v(1),20);
end
end
Also, have a look at quadgk or integral (if you're on newer Matlab).
By the way, I assume your real functions int1 and int2 are different functions? Because these functions are of course trivial to solve analytically...
Internally MATLAB will evaluate the function fun for necessary values of x, which is more than one and x is a vector. a and b are only used to describe the limits of integration. From the documentation
fun is a function handle. It accepts a vector x and returns a vector y, the function fun evaluated at each element of x. Limits a and b must be finite.
Hence, you must use .^ to operate on individual elements of vector x.