2
$\begingroup$

enter image description here

Trying to solve this question for a good 5 hours but remained stuck. My intuition tells me I am missing something trivial that I've overlooked or forgotten. I am restricted only to the function 'table', 'accumulate', 'tableform','total','range',.

Attached are my codes:

4 Table[ ((1 - Cos[n π])/(n π)^3 E^(-n π ξ) Sin[n π η]), {n, 1, 25}]

Length[sumterms3]

Total[sumterms3]

ξ = {0., 0.1, 0.2, 0., 0.1, 0.2};

η = {0.4, 0.4, 0.4, 0.5, 0.5, 0.5}

Edit: I can confirm that if I were to sub xi=0 and eta =0.4 into

 Total[sumterms3]

0.239997 would be produced. However, I am looking for a better way to do so.

$\endgroup$
2
$\begingroup$
TableForm[
 Flatten[Table[{η, ξ, 4 Total@Table[((1 - Cos[n π])/(n π)^3 E^(-n π ξ) Sin[n π η]), 
                                    {n, 1, 25}]},
              {η, {.4, .5}}, {ξ, {0, .1, .2}}], 1], 
 TableAlignments -> Center, 
 TableHeadings -> {{}, {"η", "ξ", "u(η,ξ)"}}]

Mathematica graphics

If you can't use Flatten[ ] it's a little nastier:

ps = {{0.4, 0.}, {0.4, 0.1}, {0.4, 0.2}, {0.5, 0.}, {0.5, 0.1}, {0.5, 0.2}};
TableForm[
 Table[{p[[1]], p[[2]], 
        4 Total@Table[((1 - Cos[n π])/(n π)^3 E^(-n π p[[2]]) Sin[n π p[[1]]]), 
                      {n, 1, 25}]}, 
 {p, ps}], 
 TableAlignments -> Center, 
 TableHeadings -> {{}, {"η", "ξ", "u(η,ξ)"}}]

Mathematica graphics

$\endgroup$
1
$\begingroup$
  u[\[Eta]_, \[Xi]_] := 
   Total[4 Table[((1 - Cos[n \[Pi]])/(n \[Pi])^3 E^(-n \[Pi] \[Xi]) Sin[
   n \[Pi] \[Eta]]), {n, 1, 25}]];

  list = Partition[
  Flatten[Table[{i, j, 
   u[i, j]}, {i, {0.4, 0.5}}, {j, {0, 0.1, 0.2}}]], 3];

  TableForm[list, 
  TableHeadings -> {None, {"\[Eta]", "\[Xi]", "u[\[Eta],\[Xi]]"}}]
$\endgroup$
1
$\begingroup$
pl = {0., 0.1, 0.2, 0., 0.1, 0.2};
ql = {0.4, 0.4, 0.4, 0.5, 0.5, 0.5};

fun = 4 Table[((1 - Cos[n Pi])/(n Pi)^3 E^(-n Pi p) Sin[n Pi q]), {n, 1, 25}];

res = MapThread[Total[fun /. {p -> #1, q -> #2}] &, {pl, ql}]

{0.239997, 0.177074, 0.130061, 0.250007, 0.185091, 0.136277}

 Grid[Prepend[Transpose[{
    pl /. a_Real :> PaddedForm[a, {5, 1}],
    ql /. a_Real :> PaddedForm[a, {5, 1}],
    res /. a_Real :> PaddedForm[a, {8, 6}]}],
  {"p", "q", "u(p,q)"}],
 Alignment -> Right, Dividers -> All, Spacings -> {1, 2.5}]

enter image description here

$\endgroup$
0
$\begingroup$

I did not use Greek characters, but I hope this answers your question:

sum[z_, v_] := 4 Sum[(1 - Cos[n π])/(n π)^3 Exp[-n π z] Sin[n π v], {n, 1, 25}]

Grid[Flatten[Table[{v, z, sum[z, v]}, {v, {0.4, 0.5}}, {z, {0, 0.1, 0.2}}], 1], 
    Frame -> All]
$\endgroup$
  • 1
    $\begingroup$ Dear God I forgot about the restrictions of the Homework problem !! $\endgroup$ – Lotus Dec 3 '15 at 15:06
0
$\begingroup$

Just something different (but fundamentally Tuples is useful):

f[x_, y_] := 
 4 Composition[Dot @@ # &, 
    Transpose][{(1 - Cos[# Pi])/(# Pi)^3 Exp[-# Pi x], 
      Sin[# Pi y]} & /@ Range[25]]

Using Tuples:

TableForm[{#1, #2, f[#2, #1]} & @@@ 
  Tuples[{{0.4, 0.5}, {0,0.1, 0.2}}], 
 TableHeadings -> {None, {"\[Eta]", "\[Xi]", "u(\[Eta],\[Xi])"}}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.