extracting the information from Solve
- To: mathgroup at smc.vnet.net
- Subject: [mg27784] extracting the information from Solve
- From: "Martin Richter" <mrMICE.fi at cbs.dk>
- Date: Fri, 16 Mar 2001 04:37:38 -0500 (EST)
- Organization: UNI-C
- Sender: owner-wri-mathgroup at wolfram.com
Hi, I really don't know why I'm so bad programming in Mathematica :-( Here goes my problem. I have 12 linear equation, 13 variables, and Mathematica (4.1) gives the following: f[t_] = a[0] + Sum[a[i]*Cos[2*Pi*i*t] + b[i]*Sin[2*Pi*i*t], {i, 1, 6}]; seasonTab = {{0/12, -0.5}, {1/12, -.2}, {2/12, -0.5}, {3/12, -0.5}, {4/12, 0. - .25}, {5/12, 0.1}, {6/12, 0.5}, {7/12, 0.7}, {8/12, 1.1}, {9/12, -0.3}, {10/12, -0.7}, {11/12, -0.6}}; equation = Solve[{f[0/12] == seasonTab[[1, 2]], f[1/12] == seasonTab[[2, 2]], f[2/12] == seasonTab[[3, 2]], f[3/12] == seasonTab[[4, 2]], f[4/12] == seasonTab[[5, 2]], f[5/12] == seasonTab[[6, 2]], f[6/12] == seasonTab[[7, 2]], f[7/12] == seasonTab[[8, 2]], f[8/12] == seasonTab[[9, 2]], f[9/12] == seasonTab[[10, 2]], f[10/12] == seasonTab[[11, 2]], f[11/12] == seasonTab[[12, 2]]}]; equation \!\({{a[0] -> \(-0.09583333333333333`\), a[1] -> \(-0.5684401076758503`\), a[2] -> 0.16249999999999998`, a[3] -> 0.17500000000000002`, a[4] -> \(-0.10416666666666667`\), a[5] -> \(-0.10655989232414972`\), a[6] -> 0.03750000000000004`, b[1] -> \(-0.2159882023920174`\), b[3] -> 6.543001678297708`*^-17, b[5] -> 0.11598820239201749`, b[2] -> 0.3680607966083864`, b[4] -> \(-0.07938566201357357`\)}}\) My problem is that a[i] and b[i] is only defines by a rule and not by the values, so evaluating f[1] doesn't put in the values of a[i] and b[i]. I want to assign the numbers to the a and b list so that a[0]=-0.095833333,... Of course, you can do it manually. I thought that a simple loop would do but the list is not sorted, b[3] is coming before b[2]. I have been looking in the Mathematica book, specially about Rule, Sort and equation but for no good. So, can you Sort or assign in a simple way FIA Martin ps. Is Mathematica written in C++ ? --------------------------------------- Please remove PET to reply by email