Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

That error message manifests a "misunderstanding" by Maple but it appears to be harmless.  Introduce a third parameter, k, and assign it an arbitrary value and Maple produces the correct result:

restart;
f:=x->piecewise(x>=-1/2 and x<=1/2,1);
eq:={diff(x(t),t)-sum(f(t-k*T),k=0..K)*x(t)=0,x(0)=1};
sol:=dsolve(eq, numeric, parameters=[T,K,k]);
sol(parameters=[1,3,-1]);  # the third argument is an arbitrary number
plots:-odeplot(sol, [t, x(t)], t=0..6,
    color=red, thickness=3, view=0..40
);

Or with a more interesting choice of parameters:

sol(parameters=[2,2,-1]);  # the third argument is an arbitrary number
plots:-odeplot(sol, [t, x(t)], t=0..8,
    color=red, thickness=3, view=0..13);

 

restart;

A sample constraint function.  Replace as needed:

f := (x,y) -> 2*y^2 + x - 1;

proc (x, y) options operator, arrow; 2*y^2+x-1 end proc

The constraint equation.  Change as needed:

constr_eq := unapply(f(x,y)=0.01, [x,y]);

proc (x, y) options operator, arrow; 2*y^2+x-1 = 0.1e-1 end proc

Does the equivalent of the (non-existent) command

seq(f(x,y)=0.01, x=0..1, y=0..1, 0.1);

doit := proc(xrange, yrange, stepsize)
  local i, x, y, n, xmin, xmax;
  xmin := evalf(op(1,xrange));
  xmax := evalf(op(2,xrange));
  n := 1 + round((xmax - xmin)/stepsize);
  for i from 0 to n do
    x[i] := (n-i)/n*xmin + i/n*xmax;
    # assume there is /exactly/ one solution to the following:
    y[i] := fsolve(constr_eq(x[i],yval), yval=yrange);
  end do;
  return [seq([x[i],y[i]], i=0..n)];
end proc:

ans := doit(0..1, 0..1, 0.1);

[[0., .7106335202], [0.9090909091e-1, .6778978201], [.1818181818, .6434989581], [.2727272727, .6071543162], [.3636363636, .5684908251], [.4545454546, .5269983612], [.5454545454, .4819468096], [.6363636364, .4322246890], [.7272727273, .3759835586], [.8181818182, .3096919290], [.9090909091, .2246208927], [1., 0.7071067812e-1]]

 

 

Download mw.mw

Write the summation as

sum( irem(s+r,2) * whatever, s=1 .. r-1);

because irem(s+r,2) is zero when s+r is even, and one otherwise.

 

Asking for a phase portrait for your equation is not exactly meaningful.  The responses that you have received present graphs of solutions y(x) versus x, which is not the usual meaning of a phase portrait.  A phase portrait is a plot in the phase space.

The concept of the phase space, however, pertains to autonomous differential equations.  Your equation is non-autonomous, so the graphs that you have been presented with are remotely reminiscent of phase portraits but you should be aware that they are not phase portraits.

That said, here is what I would do if I were to plot a set of graphs of y(x) versus x (not a phase portrait).

restart;

with(DEtools):

de := diff(y(x),x)=x^2-y(x)^2;

diff(y(x), x) = x^2-y(x)^2

a := 2.0;  b := 3.0;

2.0

3.0

ic := seq(y(s)=+a, s=-a..a, 0.3),
      seq(y(s)=-a, s=-a..a, 0.3),
      seq(y(-a)=s, s=-a..a, 0.3),
      seq(y(+a)=s, s=-a..a, 0.3):

DEplot(de, y(x), x=-b..b, [ic], y=-b..b,
    linecolor=black, thickness=1, arrows=none);


 

Download mw.mw

restart;

with(LinearAlgebra):

A := <
1, 0, 0, 1;
0, -1, 1, 0;
0, 1, -1, 0;
1, 0, 0, 1 >;

_rtable[18446884057743726822]

Here are A's eigenvalues and eigenvectors:

evals, U := Eigenvectors(A);

evals, U := Vector(4, {(1) = -2, (2) = 2, (3) = 0, (4) = 0}), Matrix(4, 4, {(1, 1) = 0, (1, 2) = 1, (1, 3) = -1, (1, 4) = 0, (2, 1) = -1, (2, 2) = 0, (2, 3) = 0, (2, 4) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0, (3, 4) = 1, (4, 1) = 0, (4, 2) = 1, (4, 3) = 1, (4, 4) = 0})

Make a diagonal matrix of the eigenvalues:

Lambda := DiagonalMatrix(evals);

_rtable[18446884057743703326]

We have A = U.Lambda.(1/U).  Let's verify that:

A - U . Lambda . U^(-1);

_rtable[18446884057743692134]

Here are two equivalent ways of calculating e^A.

 

Method 1:

U . MatrixExponential(Lambda) . U^(-1);

_rtable[18446884057743684062]

Method 2 (the preferred way) does not require explicitly calculating eigenvalues and eigenvectors:

MatrixExponential(A);

_rtable[18446884057743676950]

Download mw.mw

Define φ and ψψ as you already have.

Then:

r := 2^k * M;
phi_vec := Vector[column](r, i-> phi[i]);
`&psi;&psi;_vec` := Vector[row](r, j-> `&psi;&psi;`[j]);
P := phi_vec . `&psi;&psi;_vec`;

 

Aside: The symbol `&psi;&psi;` in your calculations is too cumbersome and unnecessary. Why not use a single-letter symbol such as an uppercase Ψ insteaad?

Here is a worksheet that shows the general method of assembling a matrix from smaller matrices.

I must alert you, however, to your use of M^(−1) *~ K in your worksheet. That certainly IS NOT the same as the matrix product M^(−1) . K. Which of those constructions do you have in mind?

restart;

with(LinearAlgebra):

r := 2;

2

Putting fiour rxr arbitrary matrices together:

< Matrix(r, symbol=a), Matrix(r, symbol=b);
  Matrix(r, symbol=c), Matrix(r, symbol=d) >;

_rtable[18446884266110072342]

Putting fiour rxr matrices together, the first two being the zero matrix and the identity matrix:

< ZeroMatrix(r), IdentityMatrix(r);
  Matrix(r, symbol=c), Matrix(r, symbol=d) >;

_rtable[18446884266110064990]

Download mw.mw

restart;

z := sin(2*x+3*y);

sin(2*x+3*y)

z_tmp := subs(2*x=freeze(2*x), 3*y=freeze(3*y), z);

sin(`freeze/R0`+`freeze/R1`)

thaw(expand(z_tmp));

sin(2*x)*cos(3*y)+cos(2*x)*sin(3*y)

Worksheet: cone-map.mw

restart;

Note: I advise against assigning values to parameters because it messes up the

worksheet. Instead, define the parameter values without assigning them,

like this:

params := beta=1, alpha[1]=.5;

beta = 1, alpha[1] = .5

f := beta+alpha[1]+sin(beta*x);

beta+alpha[1]+sin(beta*x)

plot(eval(f,[params]), x=0..Pi,
    labels=[x, convert("f'", symbol)(x)]):
plots:-textplot([Pi, 2.5, typeset(beta=1, ", ", alpha[1]=0.5, "\n\n")],
    align=[left], font=["Arial", 10, Bold]):
plots:-display([%,%%], axes=boxed, size = [300, 270]);

 

Download mm.mw

In this worksheet I call Maple's Explore() to visualize conic sections.  The graphics produced by Explore() cannot be shown on this web page.  Download the worksheet and load into Maple to play with it.

restart;

alpha := Pi/6;  # cone's vertex's half-angle

(1/6)*Pi

doit := proc(beta)
  plots:-display([
    plot3d([ s*cos(t)*sin(alpha), s*sin(t)*sin(alpha), s*cos(alpha)],
        s=-5..5, t=0..2*Pi, color=gold),
    plot3d([2*sin(alpha) + t*cos(beta), s, -2*cos(alpha) + t*sin(beta)],
        s=-3..3, t=-4..6, color=red)
    ], style=surface, scaling=constrained, axes=none
     , orientation=[115, 80, 0]
  );
end proc:

Explore(doit(beta),
  parameters = [beta=0..Pi/2],
  initvalues = [beta=Pi/4]
);

 

 

Download mw.mw

Addendum: The graphics may be improved significantly by adding a view option next to the orientation, as in:
    orientation=[115, 80, 0], view=[-3..6, -3..3, -4..4]

 

Maple's add() and sum() have different evaluation rules. In general, you should use add(), not sum(). if the summation range is known ahead of the time.  And if you do that, you won't need the quotation marks around a__||k.  Here is the fixed code:
restart:
p := x -> add(a__||k * x^k, k=0..5):
p(x);
p(1);
p(0);

I can't tell the purpose of the {y=-20}.  What is it supposed to do?  I am going to drop that and then fix the rest of the code.  We get:

restart;
with(PolyhedralSets):
p := PolyhedralSet([-x >= 0, -y >= 0, -z >= 0, -(1/2)*x >= 0, (-x-y)*(1/2) >= 0, (-x-z)*(1/2) >= 0]);
Plot(p);  # note the uppercase P

restart;

Let f be our Fourier series:

f := Sum(A(x,t,n), n=1..infinity);

Sum(A(x, t, n), n = 1 .. infinity)

Define F

F := (X,T,N) -> eval(f, [x=X, t=T, infinity=N]);

proc (X, T, N) options operator, arrow; eval(f, [x = X, t = T, infinity = N]) end proc

Then we will have:

F(x,t,8);

Sum(A(x, t, n), n = 1 .. 8)

Download mw.mw

restart;

G := (x,u) -> piecewise(x<u, 1/6*x^2*(1-u)^2*(3*u-2*u*x-x),
                             1/6*u^2*(1-x)^2*(3*x-2*x*u-u));

G := proc (x, u) options operator, arrow; piecewise(x < u, (1/6)*x^2*(1-u)^2*(-2*u*x+3*u-x), (1/6)*u^2*(1-x)^2*(-2*u*x-u+3*x)) end proc

int(G(x,u)*f(u), u=0..1) assuming x>0, x<1;

int(-(1/6)*f(u)*u^2*(-1+x)^2*(2*u*x+u-3*x), u = 0 .. x)+int(-(1/6)*f(u)*x^2*(-1+u)^2*(2*u*x-3*u+x), u = x .. 1)

Download mw.mw

First 35 36 37 38 39 40 41 Last Page 37 of 58