MathGroup Archive 2001

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

Search the Archive

Re: extracting the information from Solve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27827] Re: extracting the information from Solve
  • From: BobHanlon at aol.com
  • Date: Mon, 19 Mar 2001 01:29:19 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Clear[a, b, f];

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}};

soln = Chop[Solve[f[#[[1]]] == #[[2]]& /@ seasonTab]];

Since you have 13 unknowns and only 12 equations, one of the variables, b[6], 
remains unknown

f[t_] = (f[t] /. soln[[1]])

-0.5684401076758503*Cos[2*Pi*t] + 0.16249999999999998*
   Cos[4*Pi*t] + 0.175*Cos[6*Pi*t] - 0.10416666666666666*
   Cos[8*Pi*t] - 0.10655989232414974*Cos[10*Pi*t] + 
  0.03750000000000005*Cos[12*Pi*t] - 
  0.2159882023920174*Sin[2*Pi*t] + 0.3680607966083865*
   Sin[4*Pi*t] - 0.07938566201357355*Sin[8*Pi*t] + 
  0.1159882023920175*Sin[10*Pi*t] + b[6]*Sin[12*Pi*t] - 
  0.09583333333333333

Verifying that the 12 equations are satisfied 

And @@ (f[#[[1]]] == #[[2]]& /@ seasonTab)

True

However, for any value of t which is not an integer multiple of 1/12 the 
unknown will appear

f[1/Pi]

b[6]*Sin[12] - 0.2778416562693573


Bob Hanlon

In a message dated 2001/3/16 5:18:40 AM, mrMICE.fi at cbs.dk writes:

>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
>


  • Prev by Date: Re: NIntegrate problem
  • Next by Date: Re: Export MIDI?
  • Previous by thread: extracting the information from Solve
  • Next by thread: Re: extracting the information from Solve