Carl Love

Carl Love

28025 Reputation

25 Badges

12 years, 310 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

You have

ResBB:= fnormal((1-B(s))/(1-Ls(s)), 10);

Change that to

ResBB:= fnormal(factor((1-B(s))/(1-Ls(s))), 10);

I have confirmed that this reduces the degree of both the numerator and denominator from 20 to 19, and that it allows you to evaluate ResBB at s=0.

You should use simplify with side relations. Let M be your Matrix. Then the command would be

map[inline](simplify, M, {2*v13*v21*v32+v12*v21+v13*v31+v23*v32 = V});

This reduces the rational function in the example that you gave, but it does not completely eliminate the indexed variables, nor do I see how it possibly could.

The command to solve that is numtheory:-pi. It is the inverse function of ithprime.

numtheory:-pi(29);

     10

The command for decimal answers is evalf. In the case that you present, use the command

evalf(%);

The % is to refer to the result of the previous command.

Using the context menus for this is a two-step process. First use Conversions -> To List, then Approximate and select the number of digits.

Edit: Answer edited due to new information provided by Preben below.

map(collect, M, [a1, a2]);

To the best of my ability to interpret what you typed, you meant what I have below. But I am still unsure what you meant by ^() (an empty exponent). Note that square brackets cannot be substituted for parentheses in Maple. If I have transcribed your equation correctly, then it can be easily solved with fsolve.

 

Digits:= 10:

eq:= a^l - Int(((0.6*r^2+1)^b/(0.375*r^2+1)^c)^l*r, r= 0..1);

a^l = Int(((.6*r^2+1)^b/(.375*r^2+1)^c)^l*r, r = 0 .. 1)

(1)

Subs:= convert([a= 1.003225155, b= 1.813666667, c= 2.666666667], rational);

[a = 163930/163403, b = 5441/3000, c = 8/3]

(2)

fsolve(eval(eq, Subs), l);

-1776.534864

(3)

Check residual.

evalf(eval(eq, [Subs, l= %]));

-0.1e-11

(4)

 

 

Download fsolve_int.mw

At the end of the computation in Part1, include the commands

try FileTools:-Remove("MyFile.m") catch: end try;
save var1, var2, var3, "MyFile.m";

where var1, var2, var3 are the actual variable names that you want to pass, and there can be any number of them. Make sure that the filename ends with the characters .m. Start Part2 with the command

read "MyFile.m";

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).

 

 

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