Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Need help building a module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131905] Need help building a module
  • From: Gilmar Rodriguez-pierluissi <peacenova at yahoo.com>
  • Date: Mon, 28 Oct 2013 23:23:56 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • Reply-to: Gilmar Rodriguez-pierluissi <peacenova at yahoo.com>

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!


  • Prev by Date: Re: Exporting "Speak" to an audio file?
  • Next by Date: Re: Mathematica and MacOSX 10.9 Mavericks
  • Previous by thread: Re: writing tensor in mathematica
  • Next by thread: Mathematica not IEEE-754 compliant?