Carl Love

Carl Love

28070 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Hmm, am I missing something here? Why not just pick values for A and B and plot it?

X:= eval(A*exp(-a*t)+B*exp(-b*t), [a= 1, b= 2, B= 1]):
plot(
     [seq(eval(X, A= k), k= seq(4^k, k= -2..2))], t= -2..2,
     legend= [seq(A= 4^k, k= -2..2)]
);

Addressing your aside only, there is in Maple 18 the InertForm package.

InertForm:-Display(InertForm:-Parse("30 = 6*5"));

The output of this does not display correctly in MaplePrimes. In a Maple 18 worksheet, it looks just like 30 = 6*5. A more cryptic but programatically more accesible wasy to use this is

InertForm:-Display(30 = `%*`(6,5));

Computer algebraically speaking, every infix operator has a prefix form obtained by enclosing it in backquotes. If the prefix form operator is preceded by a percent sign inside the backquotes, that makes it inert.

Okay, here it is coded just with basic for loops:

MyAllNonZero:= proc(M::Matrix)
local m,n,i,j;
     (m,n):= op(1,M); #Get Matrix dimensions.
     for i to m do
          for j to n do
               if M[i,j] = 0 then return false end if
          end do
     end do;
     true
end proc:
         
recu:= proc(C::list(Matrix))
local k;
     for k to nops(C) do
          if MyAllNonZero(C[k]) then return k end if
     end do;
     0
end proc:

It's straightforward list processing. I don't see recursion helping.

recu:= proc(C::list(Matrix))
local k;
     for k to nops(C) do
          if ArrayTools:-AllNonZero(C[k]) then return k end if
     end do;
     0
end proc:

C:= [seq(LinearAlgebra:-RandomMatrix(2,2, density= .5), k= 1..1000)]:
recu(C);

     10

C[1..10];

recu(C[1..9]);

     0

 

I challenge all other entrants to beat this for time efficiency:

CartProd:= proc(L::list(list))
local S, _i, V:= _i||(1..nops(L));
     [eval(subs(S= seq, foldl(S, [V], (V=~ L)[])))]
end proc:

(m,n,p):= (2,3,3):
map[3](Matrix, m, n, CartProd([[$0..p-1] $ m*n]));

Iterators are memory efficient if the created objects are used and then immediately destroyed. It defeats the purpose if you need to hold all the created objects in memory at once.

Keeping It Simple...

You can use simplify with side relations, which is often more powerful than algsubs.

simplify(A, {Y});

In the future, please copy just your input to your posts, so that a reader can cut-and-paste a single block of code.

Change plots:-pointplot to plots[pointplot]. You must be using a very old version of Maple---from before plots was converted to a module.

It works! Using the simplify with side relations as I described a few hours ago produces the form that you are looking for. To avoid confusion in the future, do not refer to this form as a factorization of the polynomial. I don't know what to properly call it, but it's definitely not a factorization.

Using T2 from your worksheet divide.mw, I did

#For every possible pair of variables, define a new variable as their difference:
Subs:= {seq(`-`(P[])= cat(P[]), P= combinat:-choose({p||(1..4)}, 2))};

simplify(T2, Subs);

#Revert to the original variables:
subs((rhs=lhs)~(Subs), %);

The same process also worked with the final polynomial in your worksheet cubic4.mw, producing a much longer result. Remember to change p||(1..4) to p||(1..6) in the first line (the definition of Subs).

 

 

Maple can communicate via sockets. See ?Sockets .

Use $include instead of read. Note that the $ must be in the first column. See ?$include . The problem with read is that the code is read and executed.

You simply need to give a domain restriction to fsolve.

fsolve({F,Fw,Fk,Ft}, {w,k,ki,T} =~ 0..infinity);

Here's a recursive procedure for it, using option remember, though I wouldn't say that it's any more efficient than your loop.

inc1:= ex-> subsindets[flat](ex, indexed, x-> op(0,x)[op(1,x)+1]):
mytest:= proc(C::posint)
local k;
option remember;
     (inc1(thisproc(C-1)) + w[2]*mul(s[k], k= 3..C))*s[1]
end proc:
mytest(2):= s[1]*w[2]+w[1]*s[2]:
mytest(3):= inc1(mytest(2))*s[1]:
mytest(6);

Use the divide command to explicitly check whether the polynomial is divisible by (Px-Py) (over the rational numbers). If you are looking for factorizations over more complicated fields than the rationals, that is also possible, but you need to specify the field extension(s) (if they're not implied by the coefficients). Let me know.

Update: Your polynomial contains terms that have neither a p1 nor a p2. So p1-p2 couldn't possibly be a factor.

You can use a userinfo statement or a print statement to print any infomation about an ongoing computation. That includes plots. If you put a plot inside a userinfo, it needs to be inside print also, like

userinfo(1, mytest, print(plot(...)));

To "activate" the above statement, before you run the procedure do

infolevel[mytest]:= 1:

It is supported: I've uploaded animated GIF files to MaplePrimes many times. I do not use the image->include tool. I always upload files using the green uparrow (Upload File), which is the last thing on the second row of the toolbar. The animation will automatically "play" in the editor and in the post.

First 291 292 293 294 295 296 297 Last Page 293 of 395