Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 26 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

There is no direct command that I know of, but the computation is trivial. The following procedure returns a sequence of the [center, radius] pairs. Isn't that good enough for you?

Gershgorin:= proc(A::Matrix(square))
local n:= LinearAlgebra:-RowDimension(A), i, j;
     seq([A[i,i], add(abs(A[i,j]), j= 1..n) - abs(A[i,i])], i= 1..n)
end proc:
Gershgorin(LinearAlgebra:-RandomMatrix(4));
          [48, 186], [-12, 149], [-12, 52], [-30, 110]

The LinearAlgebra:-Eigenvectors command returns the matrix P and the diagonal of D.

restart:
macro(LA= LinearAlgebra):
A:= LA:-RandomMatrix(4, datatype= float[8]):
E,P:= LA:-Eigenvectors(A):
Need to make D local because it is reserved for differentiation.
local D:= LA:-DiagonalMatrix(E);
LA:-Norm(P.D.P^(-1) - A);

Essentially 0, but there is some round-off error.

Use the ?Grid package rather than the Threads package. Then there are no worries about "thread safety" because it is not a shared-memory environment. In particular, use ?Grid,Map . Example:

Integrands:= [seq(sin(k*x), k= 1..2^9)]:
Grid:-Map(evalf@Int, Integrands, x= 0..Pi);

Using this, I got 100% processor utilization on my 8-CPU machine.

The output data standarderrors is only available for a linear fit. You can easily convert your problem to a linear one. 

X1:= ln~(X); Y1:= ln~(Y -~ 1);

Now Y1 = ln(a) + b*X1.

Fit(a1+b*n, X1, Y1, n, output= [...]);

Finally a = exp(a1).

Did you have in mind a procedure to plot the circles and the eigenvalues?

restart:

Gershgorin:= proc(M::Matrix(square,complexcons))
uses LA= LinearAlgebra, P= plots;
local A:= evalf(M), n:= LA:-RowDimension(A), i, j;
     P:-display(
          [
               seq(
                    plottools:-circle(
                         [Re,Im](A[i,i]),
                         add(abs(A[i,j]), j= 1..n) - abs(A[i,i]),
                         color= COLOR(HSV, i/n, .5, .5)
                    ),
               i= 1..n
               ),
               P:-pointplot(
                    [Re,Im]~(LA:-Eigenvalues(A)),
                    color= red
               )
          ],
          scaling= constrained,
          symbol= diagonalcross, symbolsize= 16,
          _rest          
     )
end proc:

Example:

macro(LA= LinearAlgebra):

A:= LA:-RandomMatrix(5)+I*LA:-RandomMatrix(5);

A := Matrix(5, 5, {(1, 1) = 29-89*I, (1, 2) = -14+96*I, (1, 3) = 44+34*I, (1, 4) = 11-32*I, (1, 5) = 27-81*I, (2, 1) = 35+95*I, (2, 2) = 37+69*I, (2, 3) = 92-55*I, (2, 4) = 61-9*I, (2, 5) = 58+11*I, (3, 1) = -70+77*I, (3, 2) = -97+72*I, (3, 3) = 73+54*I, (3, 4) = 28+69*I, (3, 5) = 2-76*I, (4, 1) = -43-84*I, (4, 2) = -92+42*I, (4, 3) = -39+79*I, (4, 4) = -48+31*I, (4, 5) = 54+82*I, (5, 1) = -23-63*I, (5, 2) = 73+55*I, (5, 3) = 62-99*I, (5, 4) = -63-66*I, (5, 5) = 47-29*I})

Gershgorin(A);

A:= LA:-RandomMatrix(5) + I*LA:-RandomMatrix(5)+
    7*LA:-DiagonalMatrix(
         LA:-RandomVector(5)+I*LA:-RandomVector(5)
    );

A := Matrix(5, 5, {(1, 1) = 42+32*I, (1, 2) = 82-63*I, (1, 3) = 12+12*I, (1, 4) = 22+21*I, (1, 5) = 60-82*I, (2, 1) = -32+91*I, (2, 2) = 107-453*I, (2, 3) = -62+45*I, (2, 4) = 14+90*I, (2, 5) = -95-70*I, (3, 1) = -1-I, (3, 2) = 42+30*I, (3, 3) = -670-196*I, (3, 4) = 16+80*I, (3, 5) = -20+41*I, (4, 1) = 52+63*I, (4, 2) = 18+10*I, (4, 3) = -68+60*I, (4, 4) = -299-121*I, (4, 5) = -25+91*I, (5, 1) = -13-23*I, (5, 2) = -59+22*I, (5, 3) = -67-35*I, (5, 4) = 99+88*I, (5, 5) = -215-517*I})

Gershgorin(A);

 

 

Download Gershgorin.mw

 

 

You may be able to achieve what you want using the command ?plots,textplot . If you could provide a picture of what you want, I'll try to make it in Maple.

Perhaps you are referring to the tick marks on the axes? It is quite easy to change the position of them. See ?plot,tickmarks .

Don't use capital I as a variable. It is reserved for the imaginary unit. I usually use J instead when I want to use I as a variable.

Don't assign r or d.

Then the algsubs command will work.

What does "y = -0,5+7" mean? Do you mean y= -0.5*x+7? In that case,

plot([2*x-3, -0.5*x+7]);

Here is a not-fully-polished implementation of Muller's method. It will likely fail on multiple roots, and there is no checking for division by zero.

restart:

Muller:= proc(
     f::appliable, inits::[complexcons,complexcons,complexcons],
     {tolerance:= 10.^(1-Digits)}, {maxsteps:= 99}
)
local
     d1, d2, d, b, D, p, k,
     oldDigits:= Digits,
     x0:= inits[1], x1:= inits[2], x2:= inits[3],
     h1:= x1-x0, h2, h,
     fx0, fx1, fx2
 ;
     Digits:= Digits+2+ilog10(Digits);
     fx0:= evalf(f(x0));  fx1:= evalf(f(x1));
     d1:= (fx1-fx0)/h1;
     for k to maxsteps do
          h2:= x2-x1;
          fx2:= evalf(f(x2));
          d2:= (fx2-fx1)/h2;
          d:= (d2-d1)/(h2+h1);
          b:= d2+h2*d;
          D:= evalf(sqrt(b^2-4*fx2*d));
          h:= 2*fx2/(b+`if`(abs(b-D) < abs(b+d), D, -D));
          p:= x2-h;
          userinfo(2, Muller, p);
          if abs(h) < tolerance then
               userinfo(1, Muller, sprintf("Used %d steps", k));  
               return evalf[oldDigits](p)  
          end if;
          x0:= x1;  x1:= x2;  x2:= p;
          fx0:= f(x0);  fx1:= fx2;  fx2:= f(p);
          h1:= h2;  d1:= d2;
     end do;
     FAIL
end proc:
          
infolevel[Muller]:= 2:
Muller(x-> exp(x)+1, [1, 0, -1]);
Muller: -1.08197670686932642-1.58493557680537191*I
Muller: -1.27350123007187934-2.85054027345107362*I
Muller: -.381407414149884648-3.74751157829847389*I
Muller: .197272946056780758-3.14572035519676954*I
Muller: -0.16781896044693894e-1-3.15707732044571707*I
Muller: 0.9078666240418e-6-3.14209510958315899*I
Muller: 0.260490388101188484e-6-3.14159295025712521*I
Muller: -0.80434247308e-13-3.14159265359054070*I
Muller: -0.2472981852860e-18-3.14159265358979324*I
Muller: -0.247298185265482997e-18-3.14159265358979324*I
Muller: Used 10 steps
                         

Check:

evalf(Pi);

                                             3.14159265358979

Compare with fsolve:

fsolve(exp(x)+1, x=-I, complex);
                            

@MOSO1401 Sure, I can help you to make an animation. What do you want to vary? I guess that the above plot represents t=0 and you want to show how the wave evolves over time. Here is the most basic technique:

N:= 20:
for k from 1 to N do
    t:= k*Pi/N;
    frame[k]:= plot3d(sin(x+t)*cos(y+t), x= -Pi..Pi, y= -Pi..Pi)
end do:
plots:-display([seq(frame[k], k= 1..N)], insequence);

F:= eval(f(t), dsnx):
G:= eval(g(t), dsnx):

Now F and G are real-valued procedures of real arguments. For example,

F(1);
                  0.32274425109407956

If you want, you can also extract the data matrices directly from the plot. Let me know if that is what you meant.

plots:-surfdata(IS);

Everything that you want will happen if you give the command

with(RealDomain);

rem(6*x^2+5*x+1, 2*x+1, x);
                               0

The second polynomial must be a factor of the first:

factor(6*x^2+5*x+1);
                      (2 x + 1) (3 x + 1)

Maple 17's integration is more sophisticated with respect to using assumptions.

int((1+(a*x)^t)^(-1/t), x= 0..z) assuming t>0, t<1;

First 341 342 343 344 345 346 347 Last Page 343 of 395