Joe Riel

9660 Reputation

23 Badges

20 years, 7 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Are the z2, z3, etc, supposed to be unevaluated functions?  Or are the parentheses implicit multiplications that have gone bad?

Insert a break command in the else clause:

for D5d_counter from 1 to 1000 do
  increment := 0.1:
  D5d_incr := initial_D5d + increment:
  D5d_decr := initial_D5d - increment:
  energy_D5d_init := energy1d(initial_D5d);
  energy_D5d_incr:= energy1d(D5d_incr);
  energy_D5d_decr := energy1d(D5d_decr);
  #evalM(cat("plot(",convert(P[1],string), ",",convert(P[2],string), ", '+')"))
  #pointplot({[energy_D5d_init, initial_D5d]});
  if energy_D5d_incr > energy_D5d_init and energy_D5d_decr < energy_D5d_init then 
    initial_D5d := D5d_decr;
  elif  energy_D5d_incr < energy_D5d_init and energy_D5d_decr > energy_D5d_init then 
    initial_D5d := D5d_incr;
  else
    print("minima found");
    D5d_counter := 1000;
    break;  # early exit of loop
  fi;
  print(initial_D5d);
  D5d_counter;
end do;

Hmm. Now I see what you are doing.  The break command is better, but your method should work.  Are you sure the else clause is being executed?  Doe the "minima found" message print?

As Alec suggests, using member is the best approach for a one-off answer.  However, if you need to find the order of many entries, you might consider creating a table from the list:

L := [1,3,5,8,9]:
OrderL := table(L =~ [seq(1..nops(L))]):
A := Vector([2, 10, 5, 7]);
A[[1,3,4]];

You can automate this with


A[subsop(2=NULL,[seq(1..4)])];

It worked for me:
 

with(Logic):
expr := (...): # your expression, with &or; --> &or, &and; --> &and
Equivalent(expr, BooleanSimplify(expr));
                                        true

 

Are you using the correct inert and/or symbols?  Logic uses &and and &or, however, your code includes the trailing semicolons, i.e., special html/mathml characters.

Increase Digits:

restart;
LF := (1/1658880)*(1-p)^12*p^6*lambda^20/((exp(lambda))^6*(1-1/exp(lambda))^6):
Digits := 20:
Optimization:-Maximize(LF, p = .1 .. .9, lambda = 1 .. 5, maximize);
        [.47572216053128925615e-9, [p = .33333333140756364298, lambda = 3.1970590827878406950]]

The most likely cause is that the file is not located in the directory in which Maple is running. Use the currentdir command to find out from where it reads a file.

Use parse or sscanf to parse the string.

The pick procedure can be improved by inlining it:

pick := proc()
option inline;
    rnd(6, 52, 6) + 1;
end proc:

Rather than explicity tracking the cards that were picked, you could use the following technique, which maps the first valid card (1..4) to card 1, then looks for values 2..4, etc.

fouraces4 := proc(n)
local cnt,card,num;
    cnt := 0;
    to n do
        num := 0;
        do
            card := pick();
            if card > 4 then
                break;
            elif card <= num then
                next;
            elif num = 3 then
                cnt := cnt+1;
                break;
            else
                num := num+1;
            end if;
        end do;
    end do;
    return cnt;
end proc:

Note that I used the extension ".m".  That causes Maple to save using its internal format. If you chose a different extension the result will be easily readable (by eye), however, the file is generally larger and takes longer to load.

A := <<1,2>|<3,4>>:
save A, "A.m":
restart;
read "A.m":
A;
                                                 [1    3]
                                                 [      ]
                                                 [2    4]

See www.mapleprimes.com/book/cartesian-products-of-lists for several procedures for computing cartesian products in Maple.

Yes.  See the help pages for OpenMaple

 M := <<2,3>|<4,5>>; 
                                         [2    4]
                                    M := [      ]
                                         [3    5]

max(M);
                         5

You might use applyop to apply the Re function to just the rhs of the equation.  For example,

applyop(Re, 2, A[1,1]);

Or maybe

applyop(evalc@Re, 2, A[1,1]);

Given two lists you can use Equate to equate corresponding elements:

Equate[a,b,c], [1,2,3]);
                                            [a=1,b=2,c=3]

In Maple 13 you can do

[a,b,c] =~ [1,2,3];
                                  [a=1, b=2, c=3]

You could also use zip

zip(`=`, [a,b,c], [1,2,3])

For your case it is more efficient to use a do loop, the reason being that you don't have to create the intermediate lists, since all you really want to do, apparently, is make an assignment:

for i to n do
   A[i] := M[i-1] ... ;
end do:
First 81 82 83 84 85 86 87 Last Page 83 of 114