Pseudomodo

260 Reputation

8 Badges

14 years, 71 days

 

Istra balagina kish kish karia.

MaplePrimes Activity


These are answers submitted by Pseudomodo

You can do this by forgetting about the 'background' option and adding plt to each frame.

I think that looks better than using transparency, which can make either the foreground or the background look washed out.

with(plots):

plt:=densityplot(-(x^2+y^2),x=-1..1,y=-1..1):

animate(display,[plt,'plot'([sin(r)*cos(t),sin(r)*sin(t),t=0..2*Pi],thickness=10)],r=0..Pi);

By code, do you mean that you want it to produce a relation in x, with no other manual assistance?

These are probably not robust, but you could refine them.

First way: use solve. (A drawback is that the multiplicities may be wrong, which shows up for this example at the end-points which are mishandled.)

p:=expand((x-2)*(x^2 - 2*m*x + 5*m - 6)):

H:=solve({p, x<infinity},{x},allsolutions):

`or`(seq(`if`(nops(op(2*i,H))>=3,op(2*i-1,H),NULL),i=1..trunc(nops(H)/2)),
     `if`(nops(op(-1,H))>=3,Non(seq(op(2*i-1,H),i=1..trunc(nops(H)/2))),NULL));

                       Or(3 <= m, m <= 2)

Another way is to use RootFinding:-Parametric. I'm being lazy and not checking the cell boundaries (end-points) and so only get strict inequalities. But really, I ought to check the end-points and include them. It would be an improvement if RootFinding could do all this for me. It'd also be an improvement if CellPlot worked for the case of a single parameter.

p:=expand((x-2)*(x^2 - 2*m*x + 5*m - 6)):

with(RootFinding:-Parametric):
Z:=CellDecomposition([p=0],[x],[m]):

Nsols:=NumberOfSolutions(Z);

                      Nsols := [[1, 3], [2, 1], [3, 3]]

Q:=[seq(CellDescription(Z,i),i=1..nops(Nsols))];

      Q := [[[-infinity, 0, m, m - 2, 1]], [[m - 2, 1, m, m - 3, 1]], 

        [[m - 3, 1, m, infinity, 0]]]

for i from 1 to nops(Q) do
  if type(Q[i][1][4],polynom(rational,m)) and Q[i][1][5]<>0 then
    b[i]:=eval(m,(op(Q[i][1][5],solve({Q[i][1][4]},Q[i][1][3]))));
  else b[i]:=Q[i][1][4];
  end if;
  if type(Q[i][1][1],polynom(rational,m)) and Q[i][1][2]<>0 then
    a[i]:=eval(m,(op(Q[i][1][2],solve({Q[i][1][1]},Q[i][1][3]))));
  else a[i]:=Q[i][1][1];
  end if;
end do;

`or`(seq(`if`(Nsols[i][2]>=3,x>a[i] and x<b[i],NULL),i=1..nops(Q)));

              -infinity < x and x < 2 or 3 < x and x < infinity

If you use the ScientificConstants:-AddConstant command then the information you associate with it could be handled using the ScientificErrorAnalysis package.

If you don't care about that then why bother trying to make your data be "under" ScientificConstants?

If you want to implement it as a new package then start by reading the Chapter on doing that in the Programming Manual.

Why are you taking the absolute value in your assignment to ErTime? Alternatively, if you take the absolute value of the error, then why do you expect it to integrate to zero?

As shown by your first plot, at first one curve lies above, and then this switches. And ErTime may be defined as one minus the other. What's your objection to defining ErTime as the simple difference -- allowing for and retaining the sign -- without taking the absolute value?

The presence of the sign of ErTime at every point in time is what allows for error "one way" (red above green) to be compensated for later on by error "the other way" (green above red).

If you remove the absolute value from the definition of ErTime, then all the plots should make sense. The very last plot, of the integral of ErTime from zero to K, will tend to zero as K the upper limit of initegration tends to infinity. And the slope of that last plot will change sign at the same point in time that the red and green curves cross over in the first plot -- namely at the point at which ErTime itself the becomes zero, and incidentally in agreement with the middle plot.

One possibility is to give all the set entries as many trailing zeros as needed to make them each have as many digits after the decimal point as the entry with the most.

This might be helpful if you do not want them rounded yet, at the current working precision. See the last example below.

restart:

Digits:=10:

s:={Float(10.00)} union {Float(10.0)} union {Float(10.)};

                       {10.00, 10.0, 10.}

k:=min(map2(op,2,s)):
{seq(SFloat(op(1,r)*10^(-k+op(2,r)),k), r in s)};

                            {10.00}

s:={Float(10.0)} union {Float(10.000)} union {Float(-.4100000)};

                   {-0.4100000, 10.000, 10.0}

k:=min(map2(op,2,s)):
{seq(SFloat(op(1,r)*10^(-k+op(2,r)),k), r in s)};

                    {-0.4100000, 10.0000000}

s:={Float(10.00)} union {Float(10.0)} union {Float(10.0000000000000000000001)};

            {10.00, 10.0, 10.0000000000000000000001}

k:=min(map2(op,2,s)):
{seq(SFloat(op(1,r)*10^(-k+op(2,r)),k), r in s)};

     {10.0000000000000000000000, 10.0000000000000000000001}

When you write, "function" do you mean an expression? If f is twice continuously differentiable over a convex domain then a sufficient condition for f being convex is that the Hessian is positive semi-definite within that restricted domain.

Can you compute the Hessian and demonstrate that it is positive semi-definite? You might have to impose assumptions for the test, using what you know of the restricted domain.

If you obtain the dsolve result from using the first two (proper) ICs, then the resulting expression with one constant of integration poses trouble for the limit command. In Maple 13, in completely different sessions, the limit of this expression will sometimes return as undefined, and sometimes return a 0.

That is, sometimes you'll get this,

restart:

limit( (-x+exp(-x)*sin(x)+1)/(-exp(x)+exp(-x)*cos(x)+2*exp(-x)*sin(x)), x=infinity );

                                  undefined

while sometimes you'll get this,

restart:

limit( (-x+exp(-x)*sin(x)+1)/(-exp(x)+exp(-x)*cos(x)+2*exp(-x)*sin(x)), x=infinity );

                                      0

That's an ordering problem.

If it weren't for that, then you could probably just call dsolve with the first two ICs, and then take a limit as follows.

restart:

eq:=rhs(dsolve({diff(f(x),x,x,x)+diff(f(x),x,x)-2*f(x)=-2*x,
        f(0)=0,D(f)(0)=0}));

      x - _C2 exp(x) + _C2 exp(-x) cos(x) + (-1 + 2 _C2) exp(-x) sin(x)

K:=(indets(eq,name) minus {x})[1];

                                     _C2

solve(eq=1,K);

                           -x + exp(-x) sin(x) + 1          
                 -------------------------------------------
                 -exp(x) + exp(-x) cos(x) + 2 exp(-x) sin(x)

limit(simplify(solve(eq=1,K)),x=infinity);

                                      0

eval(eq,K=limit(solve(eq=1,K),x=infinity));
                             x - exp(-x) sin(x)

But sometimes that limit for finding K, above, will return undefined. That was the ordering problem. So we look for something that might be more robust. We'd prefer something fully automated, but can settle for something which relies on a little thought and human intervention.

restart:

deq := diff(f(x), x, x, x)+diff(f(x), x, x)-2*f(x) = -2*x:

eq := rhs(dsolve(deq));

          x + _C1 exp(x) + _C2 exp(-x) cos(x) + _C3 exp(-x) sin(x)

s1 := eval(eq = 0, x = 0);

                                _C1 + _C2 = 0

s2 := eval(diff(eq, x) = 0, x = 0);

                           1 + _C1 - _C2 + _C3 = 0

limit(diff(eq, x) = 1, x = infinity); # interesting

                        1 + signum(_C1) infinity = 1

s3 := limit(isolate(diff(eq, x) = 1, _C1), x = infinity);

                                   _C1 = 0
solve({s1, s2, s3});

                        {_C1 = 0, _C2 = 0, _C3 = -1}

eval( eq, % );

                             x - exp(-x) sin(x)

Another way to get those last few steps is:

s3 := map(limit, solve(diff(eq, x) = 1), x = infinity);

            {_C1 = 0, _C2 = _C2, _C3 = _C3, infinity = infinity}

s3 := remove(t->rhs(t)=lhs(t),s3); # can skip this in Maple 15

                                  {_C1 = 0}

solve({s1, s2} union s3);

                        {_C1 = 0, _C2 = 0, _C3 = -1}

eval( eq, % );

                             x - exp(-x) sin(x)

The test should occur within the loop, because you have test every row. The procedure can return as soon as it determines failure of the test for any particular row.

JacobiCondition:= proc(A)
     local MC, i, j, DimA;
     DimA:=LinearAlgebra:-ColumnDimension(A);
     for i from 1 to DimA do:
        if add(abs(A[i,j]),j=1..DimA) >= 2*abs(A[i,i]) then
           print("It's Not OK");
           return NULL;
        end if;
     end do;
     print("It's OK");
     return NULL;
end proc:

You should consider applying evalf around the references A[i,i] and A[i,j], so that it can work for Matrices with entries like sqrt(2).

Maybe you have set up foc1zF, foc2zF, and foc3zF not as you intended?

Look at the identical terms on both right and left hand side of those three equations. The terms involving lambda (or z, or F) cancel, so `solve` does not succeed for them.

This is a FAQ.

plot3d((x+y)*exp(-x^2-y^2), x = -1.7 .. 1.7, y = -1.7 .. 1.7);

 

@lgault See the attached worksheet, for some ideas for you.

jelinekmod.mw

Is the result zero?

Does it help if you add in the option --no-as-needed ?

I would think that you would need -lmaplec -lmaple -lhf -lrt at least, and in that order. Ensure that nothing that depends on librt.so comes after the -lrt since oneiric got the changed planned in natty to use --as-needed and --no-copy-dt-needed-entries as new default options.

See also here and here.

Let S be a covariance Matrix, from which it follows that it is symmetric positive definite.

Take the Cholesky factorization S=L*L' where L is lower triangular.

Suppose that

  w'*S*w < r^2

It follows that

  w'*(L*L')*w < r^2   

 (w'*L)*(L'*w) < r^2   

 (L'*w)'*(L'*w) < r^2

 sqrt((L'*w)'*(L'*w)) < sqrt(r^2)

which you may care to denote as

 norm(L'*w) < r

No use was made above of the notion that L = L' , which is good because it isn't generally true.

Replace L' by U and L by U' throughout, if you wish.

1 2 3 Page 2 of 3