Carl Love

Carl Love

28095 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Here I do the 3d plots using dsolve's parameters option. Then I paste separate plots of x(t) and y(t) together with display.

# System of two equations with a parameter:
Sol:= dsolve(
     {diff(x(t),t) = k, x(0) = 1, diff(y(t),t) = k, y(0) = -1},
     numeric, parameters= [k]
);

# x(t) and y(t) are necessarily computed at the same time. The
# procedure SOL is to avoid redoing those computations when they
# are plotted separately.
SOL:= proc(k,t)
option remember;
     Sol(parameters= [k]);
     Sol(t)
end proc;

X:= (k,T)-> eval(x(t), SOL(k,T)):
Y:= (k,T)-> eval(y(t), SOL(k,T)):

# Plot X and Y individually. Save plots to variables.
P1:= plot3d(X, -2..2, -2..2):
P2:= plot3d(Y, -2..2, -2..2):

# Piece together plots with `display`.
plots:-display([P1,P2], axes= boxed);

I have a feeling that this is not exactly what you want, but it may be the best that is possible: Use Print Preview from the File menu.

Here's an example where I compute the order of convergence of Newton's method applied to a specific function.

Newton:= proc(
     f::operator,  #function in operator form
     x0::complexcons, #initial guess of root r such that f(r)=0
     n::posint  #number of iterations
)
local
    x, N:= unapply(simplify(x - f(x)/D(f)(x)), x),
    R:= Vector(n, [N(x0)]),  
    k
;
    for k from 2 to n do
         R[k]:= N(R[k-1])
    end do;
    R #return vector of iterates
end proc:
 
#Example function:
f:= x-> x^3-1:
true_root:= 1:
Digits:= 100:
n:= 8:
R:= Newton(f, .5, n):
#Compute the logs of the absolute errors.
lnE:= map(x-> ln(abs(x-true_root)), R):
Digits:= 15:
seq(lnE[k+1]/lnE[k], k= 1..n-1);

The sequence above appears to be converging to 2. That's the order of convergence.

According to ?abs :

The derivative of abs is denoted by abs(1, x). This is signum(x) for all non-0 real numbers, and is undefined otherwise.

Therefore,

D(conjugate)(x) assuming x::real;

                   1

Maple does it this way so that the derivatives of expressions involving conjugate will simplify, as above, when appropriate assumptions are made.

 

 

 

 

I did it for the first five of your points. The idea is the same for more points. This goes through the color spectrum from red to blue, so it passes through orange, yellow, and green also.

Pts:= [[.1733, .0048], [.1726, .0048], [.1714, .0051],
[.1689, .0069], [.1644, .0109]]:
N:= nops(Pts):
plots:-pointplot(Pts, color= [seq(COLOR(HUE, (k-1)*.65/N), k= 1..N)]);

This one makes a direct transition from red ro blue, so it goes through shades of purple:

plots:-pointplot(Pts, color= [seq(COLOR(RGB, (N-k)/N, 0, k/N), k= 1..N)]);

The problem with colorstyle= HUE cycling back to red (which Acer discussed in his lengthy Reply) can be easily overcome by rescaling the colors after the PLOT structure has been generated.

Mandelbrot:= proc(x,y)
local n,c,z;
     c:= x+I*y;  z:= c;
     for n to 48 while abs(z) < 2 do  z:= z^2+c  end do;
     n
end proc:

P:= plots:-densityplot(
     Mandelbrot, -2.1..0.6, -1.2..1.2, grid= [500,500],
     colorstyle= HUE,
     axes= boxed, scaling= constrained,
     style= patchnogrid,
     labels= [Re,Im], labelfont= [HELVETICA,ROMAN,24],
     size= [500,500]  #Maple 18 only
):

#Rescale the colors:
applyop(`*`, [1,4,2], P, .85);

Remove the size option if you aren't using Maple 18. Use size=[1000,1000] for a better view in a worksheet.

A more complicated rescaling can be used. For example, one could stretch out the visually optimal green range.

The only reference that I used to write my code is the last example at ?densityplot , which does a Julia set. I am sorry that it is similar to someone else's code. It is rather obvious if you understand the Mandelbrot set and how densityplot works.

This surface is smooth and approximates the points.

A:= `<|>`(v||(1..6), w||(1..3), x1, x2, y1):
plots:-display(
     Statistics:-ScatterPlot3D(A^%T, lowess, bandwidth=2, showpoints= false, transparency= .3),
     plots:-pointplot3d(A^%T, symbol= solidsphere, color= red, symbolsize= 16)
);

Condensing Acer's ideas into a simple procedure, I get this:

FactorGroup:= proc(G::GroupTheory:-Group, N::satisfies(N-> GroupTheory:-IsNormal(N,G)))
# Returns the group G/N.
uses GT= GroupTheory;
     GT:-CustomGroup(
          GT:-LeftCosets(N,G),
          `.`= ((g1,g2)-> GT:-LeftCoset(Representative(g1) . Representative(g2), N)),
          `/`= (g-> GT:-LeftCoset(Representative(g)^(-1), N))
          `=`= ((g1,g2)-> member(Representative(g1) . Representative(g2)^(-1), N))
     )
end proc:

Example:

G:= Alt(4):
H:= SylowSubgroup(2,G):
GH:= FactorGroup(G,H);

GroupOrder(GH);

3

Edit: Procedure updated to reflect Acer's correction to a bug discussed below.

The reason that you can't change the corner entries is that doing so makes the Matrix no longer circulant---it violates the indexing function of the Matrix.

Your Matrix is equivalent to a symmetric band matrix:

N:= 8:
A:= LinearAlgebra:-BandMatrix([[-1$N-1], [2$N]], shape= symmetric);

 

Use a local declaration in your procedure, like this:

My_Proc:= proc(...parameter declarations...)
local L, P, V;

   ...procedure statements...

end proc:

It can be done like this:

Plex:= < u | v | w | x | y | z >;

for i from 2 to 5 do Plex:= Plex[[i, 1..i-1, i+1..-1]] end do;

 

while n >= 1 do
     for i from 1 to n do
          S[i]:= resultant(F[i], F[i+1], Plex[i])
     end do;
     F[i]:= S[i];
     n:= n-1
end do;

I am not sure if you are more interested in reproducing the animation in your first link or in analyzing solids of revolution as in the second (MapleSoft) link. I chose the former. Except for the coordinate axes, the following is very close to the animation in your first link. I just estimated the number of gridlines.

restart:
f:= x-> -x^3+4*x^2-3*x+1:
plots:-animate(
     #Each frame of animation has 4 pieces put together by `display`.
     plots:-display,
     [[
       #A cylindrical sector of the curved surface:
       'plot3d'(
            [r,t,f(r)], t= 0..T, r= 0..3,
            coords= cylindrical, style= wireframe, grid= [30,20]
       ),
       #A sector of the base cylinder:
       'plot3d'(
            [3,t,z], t= 0..T, z= 0..f(3),
            coords= cylindrical, style= wireframe, grid= [30,2]
       ),
       #A sector of the base disk of the base cylinder:
       'plot3d'(
            [r,t,0], t= 0..T, r= 0..3,
            coords= cylindrical, style= wireframe, grid= [30,8]
       ),
       #The curve which is being revolved:
       'plots:-spacecurve'(
             #The main curve:
            {[r,T,f(r)],
             #The 3 straight line segments of the curve:
              [[3,T,f(3)], [3,T,0], [0,0,0], [0,0,f(0)]]
             },
            r= 0..3, coords= cylindrical, thickness= 2, color= red
       )
      ], scaling= constrained, axes= normal, orientation= [90,65]
     ], T= 0..2*Pi, paraminfo= false
);

Basically, you want to plot -abs(x^x).

plot(-abs(x^x), x= -2..0);

 

 

e^x is exp(x) in Maple; e is treated simply as another variable, hence your error messages. Try this:

plot(exp(x)*ln(x), x= 0.1..10);

First 304 305 306 307 308 309 310 Last Page 306 of 395