Carl Love

Carl Love

28110 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

Does your coefficient matrix have a special sparsity pattern, such as banded or tridiagonal? 

@vs140580 My guess is that you're trying to change the vertex labels in a graph produced by my procedure for the lexicographic product of graphs, which you very recently asked about in another thread. That procedure can be easily modified to produce string vertex labels. You just need to change

(nprintf, "%a:%a")

to

(sprintf, "%A:%A")

It's in the line after the line with GT:-Graph.

@acer You're right; my mistake. But this'll produce row vectors, (FWIW):

<1 | A>[1];
<A | 1>[1];

@moh111 Here it is:

PowerOfT:= proc(e)
    evalindets(
        e, 
        specfunc(T)^{-2, -1, 2},
        proc(e) local T, p;
            (T,p):= op(e);
            if p = 2 then (applyop(`*`, 2, T, 2) + applyop(0, 2, T))/2
            elif p = -2 then -2/(applyop(`*`, 2, T, 2) + applyop(0, 2, T))
            else -1/e
            fi
        end proc
    )
end proc
:           
ProductOfTs:= proc(t) 
local Ts, NotTs, n, a, b, x;
    (Ts, NotTs):= selectremove(type, [op](t), specfunc(T));
    n:= nops(Ts);
    if n < 2 then t
    elif n=2 then 
       (a,b):= op~(2, Ts)[];
       x:= op([1,1], Ts);
       mul(NotTs)*(T(x, a+b) + T(x, abs(a-b)))/2
    else error "product of 3 or more Ts not handled"
    fi
end proc
:
Ttrans:= proc(e)
    evalindets(
        PowerOfT(frontend(expand, [e])),
        `*`,
        ProductOfTs
    )
end proc
:
p := 8*T(x, 7)*T(x, 2)+4*T(x, 5)*T(x, 1)+6*T(x, 3)*T(x, 3)+7*T(x, 1)*T(x, 4);
                                                          2
    p := 8 T(x, 7) T(x, 2) + 4 T(x, 5) T(x, 1) + 6 T(x, 3)  + 7 T(x, 1) T(x, 4)

Ttrans(p);
               15                                            
   4 T(x, 9) + -- T(x, 5) + 5 T(x, 6) + 2 T(x, 4) + 3 T(x, 0)
               2                                             

        7        
      + - T(x, 3)
        2        


 

@acer Or, either of

<1 | A>;
<A | 1>;

 

@FDS The return is optional when it's the last statement before end proc.

@Carl Love Here's an option that you may prefer because it makes them prettyprint upright with no quotes at all:

subsindets[2](E, symbol, `#mo("%A");`, nprintf);

@vs140580 Like this:

subsindets(E, symbol, convert, string);

@moh111 Can we assume the following?:

  1. In any given expression containing these functions to be simplified, the first argument (shown as x in your example) will the same throughout the expression?
  2. No term will have a product of more than 2 functions?
  3. The only possible exponents on functions are -2, -1, 0, 1, 2?

If we can assume those, it'll be quite easy. If not, it'll be more complicated, but not very complicated.

@lcz Go to help page ?updates,v2022.

@vs140580 Well, you could give my Answer in the other thread a vote up. That's the main Answer, not the Reply.

@MANUTTM You shouldn't use square brackets [ ] or curly braces { } as a replacement for parentheses (aka round brackets) ( ) for grouping and order-of-operations control in algebraic expressions. You'll need to go through the whole worksheet and change those to parentheses.

@vs140580 In the code in question, I used Maple 2022 syntax for local variable declarations. I just posted a retrofitted revision of the code in the other thread.

@vs140580 The previous code used a local variable declaration syntax that was introduced in Maple 2022. I guess you have an earlier Maple. Here's a retrofit:

LexProd:= proc(G::seq(Graph), $)
uses GT= GraphTheory;
local
    LexProd2:= proc(G::Graph, H::Graph)
    local Vg, Vh, ng, nh, Ng, Nh, i, j, J, P, k, K;
        (Vg,Vh):= op(GT:-Vertices~([G,H]));
        (ng,nh):= op(`..`~(1, nops~([Vg,Vh])));
        (Ng,Nh):= op(op~(4, [G,H]));
        P:= [seq](seq([i,j], j= nh), i= ng);
        k:= 0;
        K:= table((p-> op(p)= ++k)~(P));
        GT:-Graph(
            (curry(nprintf, "%a:%a")@((i,j)-> (Vg[i],Vh[j]))@op)~(P),                
            (
                ((i,j)-> {
                    seq(seq(K[k,J], k= Ng[i]), J= nh), 
                    seq(K[i,k], k= Nh[j])
                })
                @op
            )~(P)            
        )
    end proc
;
    if nargs=0 then error "at least 1 graph needed"
    elif nargs=1 then G[1] 
    else foldl(LexProd2, args) 
    fi
end proc
: 

 

@lcz It has nothing to do with what you typed. You entered the numbers correctly, with significands greater than 1. The string conversion changed them to a substandard form.

First 81 82 83 84 85 86 87 Last Page 83 of 710