Carl Love

Carl Love

24322 Reputation

25 Badges

9 years, 353 days
Natick, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Those are two completely different usages, which only coincidentally look similar, and neither is specifying a value of f. The command with the f, 3 is

map(series, M1, f, 3)

where M1 is actually some command that returns a matrix. The 3 is passed on to series as its third argument, which specifies the "order" of the series. Let me know if you need to know what "order" means in this context, or see the help page ?series. This 3 is indeed "arbitrary" and optional: It could be omitted or replaced by any larger integer. If omitted, the global environment variable Order is used; its default value is 6. (Order is similar to Digits, which I mention because it's a global environment variable that nearly all users are familiar with.)

The command with the f, 0 is

map(coeff, M2, f, 0) 

where M2 is also a matrix---the result of the command from the previous paragraph. The 0 is passed on to coeff as its third argument, which specifes the degree (i.e., the exponent of f) for which the coefficient is wanted. So, means the terms that don't have f. Your senior is wrong about this one being "arbitrary": Changing or omitting the 0 will lead to different results; they'll be the coefficients of some higher power of f.

Throughout all of this, is a purely symbolic independent variable. So, it doesn't have any "values", contrary to what you thought as indicated by your first sentence. Despite its name, it does not represent a function. Perhaps it'll become a function in some later usage of this code, which may justify the author's choice of the slightly confusing name f

Let me know if you need more details on any of that.

I've noticed that many of your Questions involve using solve in a for loop to solve for a variable that is absolutely trivial to solve for by hand. The following produces exactly the same results as Tom Leslie's version of your code, but it doesn't use solve:
 

restart;

delta:= table(sparse):
F:= table([0=0, 1=0, 2=A]):   

for k from 0 to 10 do
    F[k+3]:= expand(
        (
            add(
                (sin(beta)*F[k-m] - cos(beta)*delta[k-m-1])
                * (m+1)*(m+2)*F[m+2],
                m= 0..k
            )/2
            - M(k+1)*F[k+1]
        )/`*`(k+~(1,2,3))
    )
od;
       

0

-(1/24)*M(2)*A

(1/60)*sin(beta)*A^2

(1/2880)*M(4)*M(2)*A

-(1/720)*sin(beta)*M(2)*A^2-(1/12600)*M(5)*sin(beta)*A^2

(11/20160)*sin(beta)^2*A^3-(1/967680)*M(6)*M(4)*M(2)*A

(1/90720)*sin(beta)*M(4)*M(2)*A^2+(1/48384)*sin(beta)*M(2)^2*A^2+(1/362880)*M(7)*sin(beta)*M(2)*A^2+(1/6350400)*M(7)*M(5)*sin(beta)*A^2

-(1/17280)*sin(beta)^2*A^3*M(2)-(11/4536000)*sin(beta)^2*A^3*M(5)-(11/14515200)*M(8)*sin(beta)^2*A^3+(1/696729600)*M(8)*M(6)*M(4)*M(2)*A

(5/266112)*sin(beta)^3*A^4-(29/958003200)*sin(beta)*A^2*M(6)*M(4)*M(2)-(7/22809600)*sin(beta)*M(4)*M(2)^2*A^2-(1/89812800)*M(9)*sin(beta)*M(4)*M(2)*A^2-(1/47900160)*M(9)*sin(beta)*M(2)^2*A^2-(1/359251200)*M(9)*M(7)*sin(beta)*M(2)*A^2-(1/6286896000)*M(9)*M(7)*M(5)*sin(beta)*A^2

(401/958003200)*sin(beta)^2*M(4)*M(2)*A^3+(563/319334400)*sin(beta)^2*A^3*M(2)^2+(37/479001600)*sin(beta)^2*A^3*M(7)*M(2)+(37/8382528000)*sin(beta)^2*A^3*M(7)*M(5)+(1/14784000)*sin(beta)^2*M(2)*A^3*M(5)+(1/22809600)*M(10)*sin(beta)^2*A^3*M(2)+(1/544320000)*M(10)*sin(beta)^2*A^3*M(5)+(1/1741824000)*M(10)*M(8)*sin(beta)^2*A^3-(1/919683072000)*M(10)*M(8)*M(6)*M(4)*M(2)*A

-(5023/2075673600)*sin(beta)^3*A^4*M(2)-(173/1945944000)*sin(beta)^3*A^4*M(5)-(23/1132185600)*sin(beta)^3*A^4*M(8)+(23/597793996800)*sin(beta)*A^2*M(8)*M(6)*M(4)*M(2)+(17/19926466560)*sin(beta)*M(2)^2*A^2*M(6)*M(4)+(1/948879360)*sin(beta)*M(4)^2*M(2)^2*A^2-(5/456648192)*M(11)*sin(beta)^3*A^4+(29/1643933491200)*M(11)*sin(beta)*A^2*M(6)*M(4)*M(2)+(7/39141273600)*M(11)*sin(beta)*M(4)*M(2)^2*A^2+(1/154118764800)*M(11)*M(9)*sin(beta)*M(4)*M(2)*A^2+(1/82196674560)*M(11)*M(9)*sin(beta)*M(2)^2*A^2+(1/616475059200)*M(11)*M(9)*M(7)*sin(beta)*M(2)*A^2+(1/10788313536000)*M(11)*M(9)*M(7)*M(5)*sin(beta)*A^2

 

Download NoSolve_(1).mw

Your procedure can be made faster by

  1. using diff instead of D,
  2. simplifying binomial(n,k)/n! to 1/((n-k)!*k!),
  3. remembering and re-using the derivatives and factorials of smaller orders.
restart:
Taylor2V:= proc(f::algebraic, V::[name= algebraic, name= algebraic], N::posint:= Order)
local 
    v:= lhs~(V), V0:= (lhs-rhs)~(V)[], n, k, 
    `!`:= proc(n) option remember; n*thisproc(n-1) end proc,
    D:= proc(n,k)
    option remember;
        `if`(k=0, diff(thisproc(n-1, 0), v[1]), diff(thisproc(n, k-1), v[2]))
    end proc
;
    D(0,0):= f; `!`(0):= 1; #Initialize remember tables.
    add(add(eval(D(n-k,k), V)*`*`(V0^~(n-k, k))/`!`(n-k)/`!`(k), k= 0..n), n= 0..N)
end proc
:
f:= 1/(2+x*y^2):
S:= CodeTools:-Usage(Taylor2V(f, [x=0, y=0], 30)):
memory used=5.49MiB, alloc change=32.00MiB, 
cpu time=31.00ms, real time=32.00ms, gc time=15.62ms

This Answer is intended for your general education into how to make Maple procedures faster. But you'll never make this as fast as mtaylor because mtaylor (which is written in Maple) calls series (which is NOT written in Maple) using VV's trick.

The ssystem command returns a list of two items. The first item is an error code (0 meaning no error); the second item is a string containing the program's output. This string is the only part that you want.

The commands Import and ImportGraph have different syntax, and you are mixing them up. Import will take raw string data; ImportGraph requires a file or filename. Try this:

L2:= Import(
    ssystem("D:/nauty27r3/geng -c -b 6 -g")[2], 
    source= direct, format= "Graph6", output= list
);

Note that the command does not begin with "!".

However, you can verify that C6 is embeddable in S5 with a single command:

GT:= GroupTheory:
GT:-MinPermRepDegree(GT:-CyclicGroup(6));

                               5

 

Here's a procedure for it:
 

restart:

PolyToList:= (p::algebraic, V::list({name, function}))->
local T;
    sort(
        `[]`~([coeffs](collect(p, V, 'distributed'), V, T), map(degree~, [T], V)),
        #Sort by total degree with ties broken by left-to-right (wrt V) degrees:
        key= [add, op] @~ curry(op, 2)
    )
:

#Example usage:
V:= [x,y,sin(z)]:

P:= randpoly(V, terms= 16);

62*x^2-82*x*y+80*y^3-44*x^2*sin(z)^2+71*x*y^3-17*x*y*sin(z)^2-75*y^3*sin(z)-10*y*sin(z)^3-7*x^5-40*x^4*y+42*x^4*sin(z)-50*x^3*y*sin(z)+23*x^2*y*sin(z)^2+75*x^2*sin(z)^3-92*x*y^3*sin(z)+6*y*sin(z)^4

interface(rtablesize= 16):

PolyToList(P, V);

[[-82, [1, 1, 0]], [62, [2, 0, 0]], [80, [0, 3, 0]], [-10, [0, 1, 3]], [-75, [0, 3, 1]], [-17, [1, 1, 2]], [71, [1, 3, 0]], [-44, [2, 0, 2]], [6, [0, 1, 4]], [-92, [1, 3, 1]], [75, [2, 0, 3]], [23, [2, 1, 2]], [-50, [3, 1, 1]], [42, [4, 0, 1]], [-40, [4, 1, 0]], [-7, [5, 0, 0]]]

print~((Matrix@PolyToList)~(P, combinat:-powerset(V)[2..])):

Matrix(6, 2, {(1, 1) = 6*y*sin(z)^4-10*y*sin(z)^3-75*y^3*sin(z)+80*y^3, (1, 2) = [0], (2, 1) = -92*y^3*sin(z)-17*sin(z)^2*y+71*y^3-82*y, (2, 2) = [1], (3, 1) = 75*sin(z)^3+23*sin(z)^2*y-44*sin(z)^2+62, (3, 2) = [2], (4, 1) = -50*sin(z)*y, (4, 2) = [3], (5, 1) = 42*sin(z)-40*y, (5, 2) = [4], (6, 1) = -7, (6, 2) = [5]})

Matrix(3, 2, {(1, 1) = 75*x^2*sin(z)^3+42*x^4*sin(z)-7*x^5-44*x^2*sin(z)^2+62*x^2, (1, 2) = [0], (2, 1) = 6*sin(z)^4+23*x^2*sin(z)^2-50*sin(z)*x^3-40*x^4-10*sin(z)^3-17*sin(z)^2*x-82*x, (2, 2) = [1], (3, 1) = -92*sin(z)*x-75*sin(z)+71*x+80, (3, 2) = [3]})

Matrix(5, 2, {(1, 1) = -7*x^5-40*x^4*y+71*x*y^3+80*y^3+62*x^2-82*x*y, (1, 2) = [0], (2, 1) = 42*x^4-50*x^3*y-92*x*y^3-75*y^3, (2, 2) = [1], (3, 1) = 23*x^2*y-44*x^2-17*x*y, (3, 2) = [2], (4, 1) = 75*x^2-10*y, (4, 2) = [3], (5, 1) = 6*y, (5, 2) = [4]})

Matrix(10, 2, {(1, 1) = 6*sin(z)^4-10*sin(z)^3, (1, 2) = [0, 1], (2, 1) = -17*sin(z)^2-82, (2, 2) = [1, 1], (3, 1) = 75*sin(z)^3-44*sin(z)^2+62, (3, 2) = [2, 0], (4, 1) = -75*sin(z)+80, (4, 2) = [0, 3], (5, 1) = 23*sin(z)^2, (5, 2) = [2, 1], (6, 1) = -92*sin(z)+71, (6, 2) = [1, 3], (7, 1) = -50*sin(z), (7, 2) = [3, 1], (8, 1) = 42*sin(z), (8, 2) = [4, 0], (9, 1) = -40, (9, 2) = [4, 1], (10, 1) = -7, (10, 2) = [5, 0]})

Matrix(14, 2, {(1, 1) = 80*y^3, (1, 2) = [0, 0], (2, 1) = -75*y^3, (2, 2) = [0, 1], (3, 1) = 71*y^3-82*y, (3, 2) = [1, 0], (4, 1) = -92*y^3, (4, 2) = [1, 1], (5, 1) = 62, (5, 2) = [2, 0], (6, 1) = -10*y, (6, 2) = [0, 3], (7, 1) = -17*y, (7, 2) = [1, 2], (8, 1) = 6*y, (8, 2) = [0, 4], (9, 1) = 23*y-44, (9, 2) = [2, 2], (10, 1) = -50*y, (10, 2) = [3, 1], (11, 1) = -40*y, (11, 2) = [4, 0], (12, 1) = 75, (12, 2) = [2, 3], (13, 1) = 42, (13, 2) = [4, 1], (14, 1) = -7, (14, 2) = [5, 0]})

Matrix(11, 2, {(1, 1) = -7*x^5+62*x^2, (1, 2) = [0, 0], (2, 1) = 42*x^4, (2, 2) = [0, 1], (3, 1) = -40*x^4-82*x, (3, 2) = [1, 0], (4, 1) = -44*x^2, (4, 2) = [0, 2], (5, 1) = -50*x^3, (5, 2) = [1, 1], (6, 1) = 75*x^2, (6, 2) = [0, 3], (7, 1) = 23*x^2-17*x, (7, 2) = [1, 2], (8, 1) = 71*x+80, (8, 2) = [3, 0], (9, 1) = -10, (9, 2) = [1, 3], (10, 1) = -92*x-75, (10, 2) = [3, 1], (11, 1) = 6, (11, 2) = [1, 4]})

Matrix(%id = 18446746120599651622)

 

Download PolyToList.mw

I hope this helps you:
 

NULL

restart:

f:= x-> c*min(x, 1-x):

#
#Find fixed points of f:
f1x:= {solve}(x=f(x), x);

{0, c/(c+1)}

#Find 2-orbits of f, which you observed as .4 and .8:
f2x:= {solve}(x=f(f(x)), x);

{0, c/(c+1), c/(c^2+1), c^2/(c^2+1)}

f2x:= f2x minus f1x:  f1x:= [f1x[]]:  f2x:= [f2x[]]:

c:= 2:

evalf[1](f2x);

[.4, .8]

plot(
    [f@@~[0$2,1,2][], ([`$`]~)~([f1x,f2x], 2)[]], 0..1,
    style= [line$4, point$2], symbol= [solidcircle, soliddiamond],
    color= [white, red, blue, green, red, blue], symbolsize= 20,
    legend= [
        ``, #just for blank line at top of legend
        typeset~(f^~``~([0,1,2]), "\n")[],
        typeset~("\n", ["fixed point", "2-orbit"], " of  ", f, " \n")[]
    ],
    legendstyle= [location= right],
    axes= boxed, view= [(-.1..1.1)$2], scaling= constrained, size= [600$2],
    tickmarks= [(f@@0=typeset)~([f1x[], f2x[], 1])$2], gridlines
);

NULL

NULL


 

Download OrbitPlot.mw

Like this:

z:= [
    0, 0, 0, 0, 0, 0, .689376362, 1.378752724, 2.068129087, 2.757505449, 0, 1.02920355,
    2.0584071, 3.087610649, 4.116814199, 0, 1.216469264, 2.432938529, 3.649407793,
    4.865877057, 0, 1.325720912, 2.651441823, 3.977162735, 5.302883646
]:
plots:-listcontplot(
    [ListTools:-LengthSplit](z,5), axis[1,2]= [tickmarks= ([$1..5]=~[$0..4])]
);

 

The Maple and Mathematica solutions that you show are mathematically equivalent. Both will give nonreal values for any real values of the a's and b's (unless a[1,1]*b[0,2] = a[0,2]*b[1,1], in which case the discriminant is 0). The expression under the square root sign cannot be positive for any real values of the parameters because it factors as (-1)*(a[1,1]*b[0,2] - a[0,2]*b[1,1])^2.

The absence of from an expression is not a reliable indicator that the expression is real-valued. The presence of is not a reliable indicator that it is not real-valued.

For rational-coefficient polynomial equations (such as yours) with parameters, you can get solve to break down all the relevant real intervals of the parameters which produce real solutions by adding the options parametric and real:

solve(
    k^2*a[1,1]^2 + k^2*b[1,1]^2 + 4*k*a[0,2]*a[1,1] + 
    4*k*b[0,2]*b[1,1] + 4*a[0,2]^2 + 4*b[0, 2]^2 = 0, 
    k, parametric, real
);

Note that the solution below covers all degenerate cases, i.e., when the equation is not really quadratic because the coefficient of k^2 is 0 and even when the coefficient of k is also 0. The parametric option always considers those cases.
   

         

I agree that a list or sequence of vectors would be the preferred format for programmatic usage. For a displayable table, I prefer using a matrix. (I especially like the way that matricies display with their entries centered in both dimensions.) The code below does both: My procedure DiffTab returns the "raw" list of vectors, the same as Tom Leslie's doDiff. The procedures PadV and DisplayTab turn those vectors into a neatly displayable matrix.

PadV:= proc(V::Vector, n::posint)
local k:= numelems(V), OP:= j-> n-k-1+2*j;
    Vector(2*n-1, applyop~(OP, 1, op(2,V)), fill= ``)
end proc
:
DisplayTab:= (DT::list(Vector), X::Vector)-> `<|>`(PadV~([X, DT[]], numelems(X))[])
:
DiffTab:= proc(Y::Vector)
local k, r:= Y, R:= table([1=r]);
    for k from 2 to numelems(Y) do r:= r[2..] - r[..-2];  R[k]:= r od;
    convert(R, list)
end proc
:
X:= <[$1..5]>:
Y:= 1/~X:
DT:= DiffTab(Y);
<<` X` | ` Y` | [``$4][]>, DisplayTab(DT,X)>;

             

You need to change xy to x*y.

Note the diffferent output from these two:

restart:
solve(y(1)^2 = 2., y(1));

             
1.414213562, -1.414213562

{ fsolve(y(1)^2 = 2., y(1)) };
             { }

The fsolve returns no output (which I emphasized by putting the command in { }), not even an error message. Technically, the fsolve output is called NULL.

An expression like y(1) is called in Maple an unevaluated function call (or sometimes just a "function"). So, you can use a function as a variable for solve but not for fsolve. So, your call T__v_x(1000) is producing NULL output in a position where some other command is expecting a number.

 

Do you mean something like this?

#x and y coordinates of grid:
GX:= [seq](0..3, 1/3):  GY:= [seq](1..3, 1/3)
:
#x and y coordinates of highlighted points:
PX:= [seq](1/4..11/4, 1/4):  PY:= [seq](5/4..11/4, 1/4)
:
plots:-display(
    #border:
    plot(
        [[GX[1],GY[1]], [GX[1],GY[-1]], [GX[-1],GY[-1]], [GX[-1],GY[1]], [GX[1],GY[1]]],    
        color= COLOR(RGB, .3$3), thickness= 2
    ),
    #inner:
    plot(
        [
            seq([[GX[1],y],[GX[-1],y]], y= GY[2..-2]), 
            seq([[x,GY[1]],[x,GY[-1]]], x= GX[2..-2])
        ],
        color= COLOR(RGB, .5$3), thickness= 0
    ),
    #points:
    plot(
        [seq](seq([x,y], x= PX), y= PY),
        style= point, symbol= solidcircle, symbolsize= 8,
        color= red
    ),
    axes= none, scaling= constrained
);

Your general solution isn't general enough. If f is *any* differentiable function such that f(0)=1, then x0 = y0 = f is a solution to your equation. 

A basic fact about systems of equations is that the number of things that can be solved for is at most the number of equations. 

If is the list of expressions, then all that you need to do is

R:= Grid:-Map(int, L, x= 0..1);

For numeric integration, do 

R:= Grid:-Map(int, L, x= 0..1, numeric);

The command will automatically apply some rudimentary load balancing.

First 9 10 11 12 13 14 15 Last Page 11 of 356