Ronan

1072 Reputation

14 Badges

12 years, 76 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

   Is there a way to export routines from a package. The reason I ask, I was answering a question here and I needed two routines I have, that I put together a couple of years ago in a package. I used showstat copied, pasted and edited. Worked, but not great and would utterly fail with anything complicated. e.g. In the two routines pasted  below SignedArea on line 3 c[1]  is c   [1] that caused a minor problem.  

restart

NULL

"RonanRoutines:-SignedArea := proc(a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null)  local M, A;     1   if c = null then     2       A := 1/2*a[1]*b[2]-1/2*a[2]*b[1]         else     3       A := 1/2*(b[2]-c[2])*a[1]+1/2*(-b[1]+c[1])*a[2]+1/2*c[2]*b[1]-1/2*c               [1]*b[2]         end if;     4   return A  end proc:"

NULLNULL

"RonanRoutines:-CrossingNumber := proc(A::list, B::list, C::list, E::list)  local s1, s2, s3, s4;     1   s1 := RonanRoutines:-SignedArea(A,B,C);     2   s2 := RonanRoutines:-SignedArea(A,B,E);     3   s3 := RonanRoutines:-SignedArea(C,E,B);     4   s4 := RonanRoutines:-SignedArea(C,E,A);     5   if s1 = 0 and s2 = 0 and s3 = 0 and s4 = 0 then     6       'undefined'         elif 0 <= signum(s1) and signum(s2) <= 0 then     7       if 0 <= signum(s3) and signum(s4) <= 0 then     8           -1             end if         elif signum(s1) <= 0 and 0 <= signum(s2) then     9       if signum(s3) <= 0 and 0 <= signum(s4) then    10           1             end if         else    11       0         end if  end proc:  "

NULL

Download Export_from_Package.mw

In the attached, I had to find the required coefficient. Now this has a relatively straight forward set of equation (which apparently form a closed group), so it was easy enough tee see what to do. In a more complicated situation that may be very difficult to see. I was a wondering is there is a better approach to use here?
 

restart

Prove/show the coefficient of c[0] in c[1]^11 is 1/12*(1-1/5^10)NULL

eq1 := c[1]^2 = (1/5)*c[0]+(2/5)*c[1]+(2/5)*c[2]

c[1]^2 = (1/5)*c[0]+(2/5)*c[1]+(2/5)*c[2]

(1)

eq2 := c[1]*c[2] = (2/5)*c[1]+(2/5)*c[2]+(1/5)*c[3]

c[1]*c[2] = (2/5)*c[1]+(2/5)*c[2]+(1/5)*c[3]

(2)

eq3 := c[1]*c[3] = c[2]

c[1]*c[3] = c[2]

(3)

eq4 := c[2]*c[3] = c[1]

c[2]*c[3] = c[1]

(4)

eq5 := c[2]^2 = (1/5)*c[0]+(2/5)*c[1]+(2/5)*c[2]

c[2]^2 = (1/5)*c[0]+(2/5)*c[1]+(2/5)*c[2]

(5)

eq6 := c[3]^2 = c[0]

c[3]^2 = c[0]

(6)

 

expand(eq1^5)

c[1]^10 = (1/3125)*c[0]^5+(32/3125)*c[1]^5+(32/3125)*c[2]^5+(16/625)*c[0]*c[1]^4+(16/625)*c[0]*c[2]^4+(2/625)*c[0]^4*c[1]+(2/625)*c[0]^4*c[2]+(8/625)*c[0]^3*c[1]^2+(8/625)*c[0]^3*c[2]^2+(16/625)*c[0]^2*c[1]^3+(16/625)*c[0]^2*c[2]^3+(32/625)*c[1]*c[2]^4+(32/625)*c[1]^4*c[2]+(64/625)*c[1]^3*c[2]^2+(64/625)*c[1]^2*c[2]^3+(64/625)*c[0]*c[1]^3*c[2]+(96/625)*c[0]*c[1]^2*c[2]^2+(64/625)*c[0]*c[1]*c[2]^3+(16/625)*c[0]^3*c[1]*c[2]+(48/625)*c[0]^2*c[1]^2*c[2]+(48/625)*c[0]^2*c[1]*c[2]^2

(7)

C111 := lhs(%)*c[1] = expand(rhs(%)*c[2]*c[3])

c[1]^11 = (1/3125)*c[2]*c[3]*c[0]^5+(32/3125)*c[2]*c[3]*c[1]^5+(32/3125)*c[2]^6*c[3]+(16/625)*c[2]*c[3]*c[0]*c[1]^4+(16/625)*c[2]^5*c[3]*c[0]+(2/625)*c[2]*c[3]*c[0]^4*c[1]+(2/625)*c[2]^2*c[3]*c[0]^4+(8/625)*c[2]*c[3]*c[0]^3*c[1]^2+(8/625)*c[2]^3*c[3]*c[0]^3+(16/625)*c[2]*c[3]*c[0]^2*c[1]^3+(16/625)*c[2]^4*c[3]*c[0]^2+(32/625)*c[2]^5*c[3]*c[1]+(32/625)*c[2]^2*c[3]*c[1]^4+(64/625)*c[2]^3*c[3]*c[1]^3+(64/625)*c[2]^4*c[3]*c[1]^2+(64/625)*c[2]^2*c[3]*c[0]*c[1]^3+(96/625)*c[2]^3*c[3]*c[0]*c[1]^2+(64/625)*c[2]^4*c[3]*c[0]*c[1]+(16/625)*c[2]^2*c[3]*c[0]^3*c[1]+(48/625)*c[2]^2*c[3]*c[0]^2*c[1]^2+(48/625)*c[2]^3*c[3]*c[0]^2*c[1]

(8)

c[1]^11 = simplify(rhs(C111), [eq2, eq3, eq4, eq5, eq6])

c[1]^11 = (1/9765625)*(4070573*c[3]+4067448)*c[2]+(813802/9765625)*c[0]+(813802/9765625)*c[3]

(9)

coeff(rhs(%), c[0], 1)

813802/9765625

(10)

eval(1/12*(1-1/5^10))

813802/9765625

(11)

NULL


 

Download Graphs_steps.mw

Recently I have wanted to add some questions/answers to "Favourites" . I added some posts a few years ago. Now I can't figure out how do do it. A good example is this evenings question on setting up a library. How to install a library on Maple? - MaplePrimes

The answer has useful links. And this is a particular topic I tend to have difficulty with.

This is a just a general type question. Often reading questions posted to do with modules and packages I see "foo" used. I have put together some simple packages for routines I find useful. I am week in general programming knowledge. I would like to know is "foo" something special or a generic name used for testing? Is is an acronym? ...

I have a procedure where M:=[m2,m3,m4...] and I  assign the m's values from list L:=[0.1,2....]
The procedure will only run once. Rerunning will not reassign the m's.

What is the correct way to do this?

Assign_in_proc.mw

 

First 10 11 12 13 14 15 16 Last Page 12 of 28