Markiyan Hirnyk

Markiyan Hirnyk
9 years, 152 days


These are answers submitted by Markiyan Hirnyk

Two ways

10 hours ago Markiyan Hirnyk 6392

 

This can be done with Z-transform as follows.
Z := ztrans(x(n+2)-(alpha+beta)*x(n+1)+alpha*beta*x(n) = n/3^n, n, z)

z^2*ztrans(x(n), n, z)-x(0)*z^2-x(1)*z+(-alpha-beta)*(z*ztrans(x(n), n, z)-x(0)*z)+alpha*beta*ztrans(x(n), n, z) = 3*z/(3*z-1)^2

(1)

ZZ := eval(Z, [x(0) = a, x(1) = b])

z^2*ztrans(x(n), n, z)-a*z^2-b*z+(-alpha-beta)*(z*ztrans(x(n), n, z)-a*z)+alpha*beta*ztrans(x(n), n, z) = 3*z/(3*z-1)^2

(2)

ZZZ := solve(ZZ, ztrans(x(n), n, z))

-z*(9*a*alpha*z^2+9*a*beta*z^2-9*a*z^3-6*a*alpha*z-6*a*beta*z+6*a*z^2-9*b*z^2+a*alpha+a*beta-a*z+6*b*z-b-3)/((3*z-1)^2*(alpha*beta-alpha*z-beta*z+z^2))

(3)

X := invztrans(ZZZ, z, n)

(-27*(1/3)^n*alpha^2*n+9*(1/3)^n*alpha*n-18*(1/3)^n*alpha+alpha^n*b+9*alpha^n*alpha^2*b-6*alpha^n*alpha*b+3*alpha^n-3*beta^n+27*alpha^n*beta^2+27*(1/3)^n*alpha^2-27*(1/3)^n*beta^2-27*beta^n*alpha^2-18*alpha^n*beta+18*(1/3)^n*beta+18*beta^n*alpha-beta^n*b-9*alpha^n*a*beta^3+9*beta^n*a*alpha^3+6*alpha^n*a*beta^2+9*alpha^n*b*beta^2+27*(1/3)^n*beta^2*n-6*beta^n*a*alpha^2-9*beta^n*alpha^2*b-9*beta^n*b*beta^2-alpha^n*a*beta-6*alpha^n*b*beta-9*(1/3)^n*beta*n+beta^n*a*alpha+6*beta^n*alpha*b+6*beta^n*b*beta-81*alpha^n*a*alpha^2*beta^3+81*beta^n*a*alpha^3*beta^2+54*alpha^n*a*alpha^2*beta^2+54*alpha^n*a*alpha*beta^3+81*alpha^n*alpha^2*b*beta^2-54*beta^n*a*alpha^3*beta-54*beta^n*a*alpha^2*beta^2-81*beta^n*alpha^2*b*beta^2-9*alpha^n*a*alpha^2*beta-36*alpha^n*a*alpha*beta^2-54*alpha^n*alpha^2*b*beta-54*alpha^n*alpha*b*beta^2+81*(1/3)^n*alpha^2*beta*n-81*(1/3)^n*alpha*beta^2*n+36*beta^n*a*alpha^2*beta+9*beta^n*a*alpha*beta^2+54*beta^n*alpha^2*b*beta+54*beta^n*alpha*b*beta^2+6*alpha^n*a*alpha*beta+36*alpha^n*alpha*b*beta-6*beta^n*a*alpha*beta-36*beta^n*alpha*b*beta)/(81*alpha^3*beta^2-81*alpha^2*beta^3-54*alpha^3*beta+54*alpha*beta^3+9*alpha^3+27*alpha^2*beta-27*alpha*beta^2-9*beta^3-6*alpha^2+6*beta^2+alpha-beta)

(4)

The usual way is the use of the rsolve command.
sol := rsolve({x(n+2)-(alpha+beta)*x(n+1)+alpha*beta*x(n) = n/3^n, x(0) = a, x(1) = b}, x)

-(a*beta-b)*alpha^n/(-beta+alpha)-(-a*alpha+b)*beta^n/(-beta+alpha)+3*alpha^n/((-beta+alpha)*(3*alpha-1)^2)-(1/3)*(243*alpha*beta-162*alpha-162*beta+81)*(1/3)^n/((3*beta-1)^2*(3*alpha-1)^2)-3*beta^n/((-beta+alpha)*(3*beta-1)^2)+9*(n+1)*(1/3)^n/((3*beta-1)*(3*alpha-1))

(5)

``

limit(sol, beta = alpha)

(-27*alpha^n*alpha^4*n*a+27*alpha^n*a*alpha^4+27*alpha^n*alpha^3*n*a+27*alpha^n*alpha^3*n*b-27*alpha^n*a*alpha^3-9*alpha^n*alpha^2*n*a-27*alpha^n*alpha^2*n*b+9*alpha^n*a*alpha^2+alpha^n*alpha*n*a+9*alpha^n*alpha*n*b+27*(1/3)^n*alpha^2*n-alpha^n*a*alpha+9*alpha^n*alpha*n-alpha^n*n*b-9*(1/3)^n*alpha*n-18*alpha^n*alpha-3*alpha^n*n+18*(1/3)^n*alpha)/(27*alpha^4-27*alpha^3+9*alpha^2-alpha)

(6)

sol1 := rsolve({x(n+2)-2*x(n+1)*alpha+(alpha*alpha)*x(n) = n/3^n, x(0) = a, x(1) = b}, x)

-(-2*a*alpha+b)*alpha^n/alpha+(-a*alpha+b)*(n+1)*alpha^n/alpha+9*(n+1)*(1/3)^n/(3*alpha-1)^2-(-3+27*alpha)*alpha^n/((3*alpha-1)^3*alpha)-(1/3)*(81*alpha-81)*(1/3)^n/(3*alpha-1)^3+3*(n+1)*alpha^n/(alpha*(3*alpha-1)^2)

(7)

normal(sol1)

-(27*alpha^n*alpha^4*n*a-27*alpha^n*a*alpha^4-27*alpha^n*alpha^3*n*a-27*alpha^n*alpha^3*n*b+27*alpha^n*a*alpha^3+9*alpha^n*alpha^2*n*a+27*alpha^n*alpha^2*n*b-9*alpha^n*a*alpha^2-alpha^n*alpha*n*a-9*alpha^n*alpha*n*b-27*(1/3)^n*alpha^2*n+alpha^n*a*alpha-9*alpha^n*alpha*n+alpha^n*n*b+9*(1/3)^n*alpha*n+18*alpha^n*alpha+3*alpha^n*n-18*(1/3)^n*alpha)/((3*alpha-1)^3*alpha)

(8)

eval(sol, beta = -alpha)

-(1/2)*(-a*alpha-b)*alpha^n/alpha-(1/2)*(-a*alpha+b)*(-alpha)^n/alpha+(3/2)*alpha^n/(alpha*(3*alpha-1)^2)-(1/3)*(-243*alpha^2+81)*(1/3)^n/((-3*alpha-1)^2*(3*alpha-1)^2)-(3/2)*(-alpha)^n/(alpha*(-3*alpha-1)^2)+9*(n+1)*(1/3)^n/((-3*alpha-1)*(3*alpha-1))

(9)

``

``

See Z-transform for info.

Download two_ways.mw

Syntax

22 hours ago Markiyan Hirnyk 6392

First, the cite frome Maple help to solve:

"If the output of the solve command is a piecewise-defined expression, then the assuming command can be used to isolate the desired solution(s). If the output is not piecewise-defined, in particular, if the output is constant, assumptions on the independent variables may be ignored. If there are parameters in the input equations, the solve command will use those assumptions in its computations. See examples below".

Also the solve command does not accept the assumption of type <>. Such assumtion should be splitted in the two assumptions: a<1 or a>1 instead of a<>1.

This works as desired.

[RealDomain[solve]({a > -1 or a<-1, a > 1 or a <1, (1/(a-1)-1/(a+1))*(2*a^2-2)/a = 4/surd(2, 2)})];


This is a hard system because of singular lines of its LHS (e. g. v=-1).

The command

outputs

Try a larger value of the number option and more Digits and tolerances. Your constraints are wrongly formulated: numerical solvers do not accept any strict inequalities, treating the ones as unstrict inequalities.

Addition

23 hours ago Markiyan Hirnyk 6392

@Markiyan Hirnyk The command

eq:=[2*x-0.2e-1*y-2.04*sqrt(-v^2+1)*v, 2*y-0.2e-1*x-2.16*sqrt(-u^2+1)*u, 2*u+2.16*u^2*y/sqrt(-u^2+1)-2.16*sqrt(-u^2+1)*y, 2*v+2.04*v^2*x/sqrt(-v^2+1)-2.04*sqrt(-v^2+1)*x] :

solve(convert(eq,rational));

finds {u=0, v=0, x=0, y=0}, and other real solutions, and a lot of complex ones:

evalf(%);

 

 

 

By kernelopts(cpulimit)

Yesterday at 11:09 AM Markiyan Hirnyk 6392

This can be done as follows.

kernelopts(cpulimit = 600*Unit('s'));
kernelopts(cpulimit);

                              600
solve(sys, var);

The process of the solution will be stopped in 600 s if an output is not produced.
See ?kernelopts and ?Units for info.

Take a look at ?dsolve and ?eval .

Edit. The link to eval is added.

Yes

April 17 2015 Markiyan Hirnyk 6392

The DirectSearch package should be downloaded from http://www.maplesoft.com/applications/view.aspx?SID=101333 and installed in your Maple >=12. In particular, that package includes the SolveEquations command. Let us try it.

DirectSearch:-SolveEquations(abs(a-b)+sqrt(2*b+c)+c^2-c+1/4 = 0, tolerances = 10^(-14), AllSolutions, solutions = 2);



The output suggests {a = -1/4, b = -1/4, c = 1/2} is the only solution of the equation under consideration. Using the assume=integer option, one can verify that guess.

DirectSearch:-SolveEquations(eval(abs(a-b)+sqrt(2*b+c)+c^2-c+1/4 = 0, [a = (1/4)*A, b = (1/4)*B, c = (1/4)*C]), {abs(A) <= 10^4, abs(B) <= 10^4, abs(C) <= 10^4}, tolerances = 10^(-14), AllSolutions, solutions = 2, assume = integer, evaluationlimit = 30000);


 


 

Another way

April 15 2015 Markiyan Hirnyk 6392

ydotdot := solve(convert(Eq1, rational),diff(y1(t), t, t))

Bug in CDF

April 12 2015 Markiyan Hirnyk 6392

Let us consider

with(Statistics);
CDF(cos(RandomVariable(Normal(0, 1))), x);
.

The above is not correct: it should be 1 instead of erf(1/2*Pi*sqrt(2)) in the last  line.

Probability(cos(RandomVariable(Normal(0, 1))) < 2);

                               1

These notions seem to be inconsistent in the case of a finite field. There may be no eigenvalues at all.

Here is an example of such calculation in the case of Z[7].

 

restart; randomize(); with(LinearAlgebra[Modular])

[AddMultiple, Adjoint, BackwardSubstitute, Basis, CharacteristicPolynomial, ChineseRemainder, Copy, Create, Determinant, Fill, ForwardSubstitute, Identity, IntegerCharacteristicPolynomial, IntegerDeterminant, IntegerLinearSolve, Inverse, LUApply, LUDecomposition, LinearSolve, MatBasis, MatGcd, MatrixPower, Mod, Multiply, Permute, Random, Rank, RankProfile, RowEchelonTransform, RowReduce, Swap, Transpose, ZigZag]

(1)

``

M := Random(7, 3, 4, integer)

Matrix([[1, 0, 5, 0], [0, 1, 1, 0], [0, 0, 0, 0]])

(2)

Fill(7, 0, M, 1 .. -1, 4); 1; M; 1; CharacteristicPolynomial(7, M[1 .. 3, 1 .. 3], x)

x^3+4*x^2+4*x+3

(3)

msolve(%, 7)

{x = 2}, {x = 4}

(4)

M[1 .. 3, 1 .. 3] := M[1 .. 3, 1 .. 3]-2*Identity(7, 3, integer)

Matrix([[-2, 4, 1], [5, 1, 5], [0, 5, -2]])

(5)

LinearSolve(7, M, 1)

M

Matrix([[1, 0, 5, 0], [0, 1, 1, 0], [0, 0, 0, 0]])

(6)

``

See ?LinearAlgebra[Modular] for info.

Download eigen.mw

Suggestion

April 07 2015 Markiyan Hirnyk 6392

How about this in Maple 2015?

dataplot(op(1, Surface), 'contour3d');

plots:-display([dataplot(op(1, Surface), 'contour3d'), dataplot(op(2, Surface), 'contour3d')]);

See ?dataplot for info.

 

One way

April 06 2015 Markiyan Hirnyk 6392

One of the possible versions is as follows (see https://en.wikipedia.org/wiki/Convolution for the definition).

 

restart; f := unapply(Heaviside(t)-Heaviside(t-2), t)

g := unapply(t*Heaviside(t)-(t-4)*Heaviside(t-4), t):

plots:-animate(plot, [int(f(t)*g(x-t), t = -infinity .. infinity), x = -a .. a, thickness = 3], a = 0 .. 8)

 

``

``

 

Download animation_of_convolution.mw

The answer depends on the ranges of the parameters. I guess p, P[a], etc stand for probabilities. For example,

 

ineq := (P[A]*(p-w)/(1-P[A])-c)*H[A]+(w-P[A]*(p-w)/(1-P[A]))*P[A]*H[A]+w[u]*P[B]*(1-P[A])*H[B] < (P[B]*(p-w)/(1-P[B])-c)*H[B]+(w-P[B]*(p-w)/(1-P[B]))*P[B]*H[B]+w[u]*P[A]*(1-P[B])*H[B]:
``

indets(ineq, name)

{c, p, w, H[A], H[B], P[A], P[B], w[u]}

(1)

eval(ineq, {c = 1, p = .5, w = 2, H[A] = .3, H[B] = .7, P[A] = .4, P[B] = .6, w[u] = .6})

-0.888000000e-1 < -.422800000

(2)

``


implies the inequality is not true in the general case.

Download test.mw

 

 

in view of


T1 := simplify(expand((1/6930)*exp(-(1/7938)*(X[4]-933)^2)*exp(-(1/6050)*(X[2]-805)^2)/((1+exp((1/50)*X[4]-(1/50)*X[2]))*Pi)), power);
``

(1/6930)*exp(-(1/7938)*X[4]^2+(311/1323)*X[4]-11567201/53361-(1/6050)*X[2]^2+(161/605)*X[2])/((1+exp((1/50)*X[4]-(1/50)*X[2]))*Pi)

(1)

Optimization:-Maximize(evalf(eval(T1, [X[4] = 5])))

[0.668071003202131933e-98, [X[2] = HFloat(1.0)]]

(2)

``


Download few_terms.mw

1 2 3 4 5 6 7 Last Page 1 of 125