Find out Lipschitz constant L - matlab

I have an assignment in which I have to prove that the largest Lipschitz constant L for enter image description here this function in the link is λmax(ATranspose*A).I would be very grateful to anyone who helps.Thank you in advance.

As a general rule for an non-analytic matrix A (i.e. you don't have a way to get that value via classic mathematical analysis), you want to use the Power Method.

Related

Defining a natural variable n in TI-Nspire CAS

I'm wondering if it's possible to define a natural variable n in TI-Nspire CAS. For example I'd like to write:
You can't define your own natural variables. However, Nspire has the following special variables you can use:
#n0...#n255: Restricted to natural numbers
#c0...#c255: Restricted to real numbers
You can replace the original variables with them by hand or for convience just put |x=#n0 and y=#n1 at the end of line.
Example: You are calculating fourier coefficients and know that variable k will only get real numbers from Σ operation. Replacing k with #n1 will simpilfy the function.
Picture
(Calculator needs to be in RAD mode if you want to try)
The answer is no. Variables in NSpire store a value. A variable has no type. Solve might return #n1 in a result to indicate an arbitrary natural number, but you can tell solve to look for integer solutions only.

Modelica annotation derivative: noDerivative versus zeroDerivative

I have successfully used annotation(derivative) in Modelica functions. Now I have reached a point where I think I need to use zeroDerivative or noDerivative, but from the specification I just do not understand what is the difference, and when to use what.
https://specification.modelica.org/v3.4/Ch12.html#declaring-derivatives-of-functions
It seems zeroDerivative is for time-constant parameters??
Does somebody have a simple example?
Use zeroDerivative to refer to inputs that are non-varying, i.e. parameters or constant values.
Use noDerivative for signals that do not have a derivative value. For example if an input signal comes from an external function.
The important case for noDerivative is when the input is "redundant".
As an example consider the computation of density for some media in MSL:
The density computation is found in Modelica.Media.R134a.R134a_ph.density_ph (note this does not contain any derivative in itself):
algorithm
d := rho_props_ph(
p,
h,
derivsOf_ph(
p,
h,
getPhase_ph(p, h)));
where the top function called is:
function rho_props_ph
"Density as function of pressure and specific enthalpy"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
input SI.SpecificEnthalpy h "Specific enthalpy";
input Common.InverseDerivatives_rhoT derivs
"Record for the calculation of rho_ph_der";
output SI.Density d "Density";
algorithm
d := derivs.rho;
annotation (
derivative(noDerivative=derivs) = rho_ph_der ...);
end rho_props_ph;
So the derivs-argument is sort of redundant and is given by p and h; and we don't need to differentiate it again. If you send in a derivs-argument that isn't given in this way may give unpredictable result, but describing this in detail would be too complicated. (There was some idea of noDerivative=something - but even just specifying it turned out to be too complicated.)
For zeroDerivative the corresponding requirement is that the arguments have zero derivative; that is straightforward to verify and if non-zero we cannot use the specific derivative (it is possible to specify multiple derivatives and use another derivative one for that case).

Maxima simplify expression with diff

Let's assume a is a constant and x is my variable with respect to time, so basically x(t).
Then in Maxima , what is the best way to replace 'diff(a*x,t) with a*'diff(x,t) automatically without use subst command.
The reason I don't to use subst is that I have many variables and higher order derivatives. It is not efficient to use subst to replace all the occurrences.
Thanks.
UPDATE
I have tried with depends(x,t) command, but it only works with the simple case. Here is an minimal example of my situation.
depends([x,y],t);
eq1:diff(x,t)-b=c;
eq2:subst([x=a*y],eq1);
sol_dy=solve(eq2,diff(y,t))
Of course here a,b,c are constants and x, y are variables on t.
Maxima can not solve diff(y,t) directly. How do deal with it?
I see that 'diff(...) (i.e. derivative noun expression) isn't linear (doesn't distribute over + and doesn't factor out constants) but diff(...) (verb expression) is linear. That's a misfeature, at least.
I was going to suggest declare(nounify(diff), linear) but that makes derivatives come out as 0 in your example ... this is probably a bug, I'll have to think more about it.
Try ev(eq2, nouns); to re-evaluate the derivatives as verbs -- I think that should cause the constant to factor out.

Prove NP-completeness of CLIQUE-OR-INDEPENDENT-SET

First of all, I want to mention that this is my homework. However, to solve my problem I can use any literature I want.
Even though I think that problem is clear from its name, I will give it description: "For given undirected graph G and given integer k, does G contain totally connected (clique) subgraph of size k or totally disconnected subgraph (independent set) of size k."
I know about polynomial reductions from 3-SAT to CLIQUE and from 3-SAT to INDEPENDENT-SET. (http://mlnotes.com/2013/04/29/npc.html) However, I have problem with this one because I cannot combine those two reductions. I also tried reduction from CLIQUE to CLIQUE-OR-INDEPENDENT-SET but without much success.
So I would really appreciate any hints!
Thanks in advance.
I found out reduction from problem INDEPENDENT-SET to CLIQUE-OR-INDEPENDENT-SET. All you need to do is to add n isolated vertices to graph G (which is an instance of INDEPENDENT-SET and has n vertices). Let call this newly created graph G' (instance of CLIQUE-OR-INDEPENDENT-SET). Then it is not hard to prove that G has k independent-set iff G' has n+k independent-set of clique (since, by construction, it cannot have n+kclique).

How to get the most frequent value of vector on Matlab ?

I have a vector A that contains let say [1,2,2,4]. I am looking for a way to get the most frequent value on A (here 2).
This is more a statistical question. The technical term for your request is mode.
So, in MATLAB, you can simply do:
A=[1,2,2,4]
[my_value,my_frequency]=mode(A)