Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Need help building a module
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Gilmar Rodriguez-pierluissi

Posts: 18
Registered: 5/4/11
Need help building a module
Posted: Oct 28, 2013 11:14 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear Math Group Friends:

Starting with the following three sets:

Z = {0};

R = {1, 3, 4, 9, 10, 12, 13, 27, 28, 30, 31, 36, 37, 39, 40};

L = {1, 3, 4, 9, 10, 12, 13};

First do the following evaluations (the results of the evaluations are included):
(************************)
R[[1]] - Z[[1]]
1
(************************)
R[[2]] - Z[[1]]
3
R[[2]] - L[[1]]
2
(************************)
R[[3]] - Z[[1]]
4

(** The following two evaluations produce values (i.e.; 3 and 1) that already occurred in the above evaluations and therefore are discarded. The discarted evaluations (and their results) are
surrounded by (** **) to identify them: **)

(** R[[3]]-L[[1]] **)
(** 3 **)

(** R[[3]]-L[[2]] **)
(** 1 **)

(************************)
R[[4]] - Z[[1]]
9
R[[4]] - L[[1]]
8
R[[4]] - L[[2]]
6
R[[4]] - L[[3]]
5
(************************)
R[[5]] - Z[[1]]
10
(** R[[5]]-L[[1]] **)
(** 9 **)
R[[5]] - L[[2]]
7
(** R[[5]]-L[[3]] **)
(** 6 **)
(** R[[5]]-L[[4]] **)
(** 1 **)
(************************)

R[[6]] - Z[[1]]
12
R[[6]] - L[[1]]
11
(** R[[6]]-L[[2]] **)
(** 9 **)
(** R[[6]]-L[[3]] **)
(** 8 **)
(** R[[6]]-L[[4]]**)
(** 3 **)
(** R[[6]]-L[[5]] **)
(** 2 **)
(************************)

R[[7]] - Z[[1]]
13
(** R[[7]]-L[[1]] **)
(** 12 **)
(** R[[7]]-L[[2]] **)
(** 10 **)
(** R[[7]]-L[[3]] **)
(* 9 *)
(** R[[7]]-L[[4]] **)
(** 4 **)
(** R[[7]]-L[[5]] **)
(** 3 **)
(** R[[7]]-L[[6]] **)
(** 1 **)
(************************)
R[[8]] - Z[[1]]
27
R[[8]] - L[[1]]
26
R[[8]] - L[[2]]
24
R[[8]] - L[[3]]
23
R[[8]] - L[[4]]
18
R[[8]] - L[[5]]
17
R[[8]] - L[[6]]
15
R[[8]] - L[[7]]
14
(************************)
R[[9]] - Z[[1]]
28
(** R[[9]]-L[[1]] **)
(** 27 **)
R[[9]] - L[[2]]
25
(** R[[9]]-L[[3]] **)
(** 24 **)
R[[9]] - L[[4]]
19
(** R[[9]]-L[[5]] **)
(** 18 **)
R[[9]] - L[[6]]
16
(** R[[9]]-L[[7]] **)
(** 15 **)
(************************)
R[[10]] - Z[[1]]
30
R[[10]] - L[[1]]
29
(** R[[10]]-L[[2]] **)
(** 27 **)
(** R[[10]]-L[[3]] **)
(** 26 **)
R[[10]] - L[[4]]
21
R[[10]] - L[[5]]
20
(** R[[10]]-L[[6]] **)
(** 18 **)
(** R[[10]]-L[[7]] **)
(** 17 **)
(************************)
R[[11]] - Z[[1]]
31
(** R[[11]]-L[[1]] **)
(** 30 **)
(** R[[11]]-L[[2]] **)
(** R[[11]]-L[[3]] **)
(** 27 **)
R[[11]] - L[[4]]
22
(** R[[11]]-L[[5]] **)
(** 21 **)
(** R[[11]]-L[[6]] **)
(** 19 **)
(** R[[11]]-L[[7]] **)
(** 18 **)
(************************)
R[[12]] - Z[[1]]
36
R[[12]] - L[[1]]
35
R[[12]] - L[[2]]
33
R[[12]] - L[[3]]
32
(** R[[12]]-L[[4]] **)
(** 27 **)
(** R[[12]]-L[[5]] **)
(** 26 **)
(** R[[12]]-L[[6]] **)
(** 24 **)
(** R[[12]]-L[[7]] **)
(** 23 **)
(************************)
R[[13]] - Z[[1]]
37
(** R[[13]]-L[[1]] **)
(** 36 **)
R[[13]] - L[[2]]
34
(** R[[13]]-L[[3]] **)
(** 33 **)
(** R[[13]]-L[[4]] **)
(** 28 **)
(** R[[13]]-L[[5]] **)
(** 27 **)
(** R[[13]]-L[[6]] **)
(** 25 **)
(** R[[13]]-L[[7]] **)
(** 24 **)
(************************)
R[[14]] - Z[[1]]
39
R[[14]] - L[[1]]
38
(** R[[14]]-L[[2]] **)
(** 36 **)
(** R[[14]]-L[[3]] **)
(** 35 **)
(** R[[14]]-L[[4]] **)
(** 30 **)
(** R[[14]]-L[[5]] **)
(** 29 **)
(** R[[14]]-L[[6]] **)
(** 27 **)
(** R[[14]]-L[[7]] **)
(** 26 **)
(************************)
R[[15]] - Z[[1]]
40
(** R[[15]]-L[[1]] **)
(** 39 **)
(** R[[15]]-L[[2]] **)
(** 37 **)
(** R[[15]]-L[[3]] **)
(** 36 **)
(** R[[15]]-L[[4]] **)
(** 31 **)
(** R[[15]]-L[[5]] **)
(** 30 **)
(** R[[15]]-L[[6]] **)
(** 28 **)
(** R[[15]]-L[[7]] **)
(** 27 **)

Next; sort the undiscarted evaluations in descending order (i.e. sort the values that the undiscarted evaluation attain) as follows (the results of the evaluations are also included):
R[[1]] - Z[[1]]
1
(*******************)
R[[2]] - L[[1]]
2
(*******************)

R[[2]] - Z[[1]]
3
(******************)
R[[3]] - Z[[1]]
4
(*****************)
R[[4]] - L[[3]]
5
(*****************)
R[[4]] - L[[2]]
6
(*****************)
R[[5]] - L[[2]]
7
(*****************)
R[[4]] - L[[1]]
8
(*****************)
R[[4]] - Z[[1]]
9
(*****************)
R[[5]] - Z[[1]]
10
(****************)
R[[6]] - L[[1]]
11
(****************)
R[[6]] - Z[[1]]
12
(***************)
R[[7]] - Z[[1]]
13
(***************)
R[[8]] - L[[7]]
14
(***************)
R[[8]] - L[[6]]
15
(***************)
R[[9]] - L[[6]]
16
(***************)
R[[8]] - L[[5]]
17
(***************)
R[[8]] - L[[4]]
18
(***************)
R[[9]] - L[[4]]
19
(****************)
R[[10]] - L[[5]]
20
(****************)
R[[10]] - L[[4]]
21
(****************)
R[[11]] - L[[4]]
22
(****************)
R[[8]] - L[[3]]
23
(****************)
R[[8]] - L[[2]]
24
(***************)
R[[9]] - L[[2]]
25
(***************)
R[[8]] - L[[1]]
26
(***************)
R[[8]] - Z[[1]]
27
(***************)
R[[9]] - Z[[1]]
28
(***************)
R[[10]] - L[[1]]
29
(***************)
R[[10]] - Z[[1]]
30
(***************)
R[[11]] - Z[[1]]
31
(**************)
R[[12]] - L[[3]]
32
(**************)
R[[12]] - L[[2]]
33
(**************)
R[[13]] - L[[2]]
34
(**************)
R[[12]] - L[[1]]
35
(**************)
R[[12]] - Z[[1]]
36
(**************)
R[[13]] - Z[[1]]
37
(**************)
R[[14]] - L[[1]]
38
(**************)
R[[14]] - Z[[1]]
39
(**************)
R[[15]] - Z[[1]]
40

What I need is a module f[n] such that if I evaluate:
f[1] the module returns {Z[[1]], R[[1]]} = {0,1}.
Similarly;
f[2] = {L[[1]], R[[2]]} = {1,3}
f[3] = {0,3}
f[4] = {0,4}
f[5] = {4, 9}
etc.
f[40]= {0, 40}.

Sorry about the lengthy presentation and thank you for your help!



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.