Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You are using the feasible command from the simplex package and the LPSolve command from the Optimization package. So you are not getting contradictory results from the simplex package. Try using minimize from the simplex package. (This may take too much time.) The problem with LPSolve may be one of precision: It may work if you increase Digits, or specify method= activeset.

Please provide a worksheet if you need further help.

Include the following in your initialization file:

Histogram:= proc({frequencyscale:= ':-absolute'})
     Statistics:-Histogram(_rest, ':-frequencyscale'= frequencyscale)
end proc:
protect(Histogram):

Then when you want to use it, invoke :-Histogram regardless of whether Statistics has been loaded (with with).

remove(has, indets(T), x);

Here is a little procedure that you can use that will take any expression, find the floats that have zero fractional part, and convert those floats to the corresponding integer. It will also find floats with trailing zeros and truncate those zeros. If you apply this to expressions before making a comparison, then they will compare as equal when you want them to. You may find this more convenient than using verify.

 

NormalizePointZero:= (expr::anything)->
     subsindets[flat](
          expr, float,
          proc(x::float)
          local m, e, q;
               if x=trunc(x) then trunc(x)
               else
                    (m,e):= op(x);
                    while irem(m,10,'q') = 0 do e:= e+1; m:= q end do;
                    Float(m,e)
               end if
          end proc
     )
:    

S:= {20, 20., 20.00, 20.5, 20.50};

{20, 20.00, 20., 20.50, 20.5}

(1)

NormalizePointZero(S);

{20, 20.5}

(2)

Comparison:= [20] = [20.];

[20] = [20.]

(3)

``

evalb(Comparison);

false

(4)

evalb(NormalizePointZero(Comparison));

true

(5)

evalb(20.5*x+20 = 20.50*x+20.);

false

(6)

evalb(NormalizePointZero(20.5*x+20 = 20.50*x+20.));

true

(7)

``

 

Download Normalize_point_zero.mw

If you tell Maple that all the variables represent real numbers, then it recognizes the final equality as true. You do this not with the context menu but with the command

is(%) assuming real;

which must be entered immediately after the equality Q2 = ... is entered.

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:

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