Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Sundry Questions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61152] Re: Sundry Questions
  • From: "Matt" <anonmous69 at netscape.net>
  • Date: Tue, 11 Oct 2005 03:22:24 -0400 (EDT)
  • References: <diabu7$ikb$1@smc.vnet.net><did2le$qco$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Jens,
  Thanks for your response.  I have a couple of follow up questions for
you if you please (the other answers were crystal clear):

Your response (a):  I was amazed at first that this worked, but after
looking into 'HoldAll' and 'Evaluate', it began to dawn on me what was
going on.  I just want to make sure that I understand it.  Because
ParametricPlot has the 'HoldAll' attribute, the list of rules is not
'recognized' as a list of rules and consequently, when the algorithm
for ParametricPlot evaluates the list with explicit values of 't', what
it gets back from evaluating the list of rules is gibberish, whereas if
Evaluate is used first, the algorithm for ParametricPlot 'recognizes'
that there is a list and 'threads' over the various rules for each
explicit value of 't'.  At first I thought Evaluate changes the
expression somehow, but executing this:

Cell[BoxData[{
    RowBox[{
      StyleBox[
        RowBox[{
          RowBox[{"severalSols", " ", "=", " ",
            RowBox[{"Table", "[",
              RowBox[{
                RowBox[{"DSolve", "[",
                  RowBox[{
                    RowBox[{"{",
                      RowBox[{
                        RowBox[{
                          RowBox[{
                            RowBox[{"x", "'"}], "[", "t", "]"}], "==",

                          RowBox[{"2", " ",
                            RowBox[{"y", "[", "t", "]"}]}]}], ",",
                        RowBox[{
                          RowBox[{
                            RowBox[{"y", "'"}], "[", "t", "]"}], "==",

                          RowBox[{
                            RowBox[{
                              RowBox[{"-", "1"}], "/", "4"}], " ",
                            RowBox[{"x", "[", "t", "]"}]}]}], ",",
                        RowBox[{
                          RowBox[{"x", "[", "0", "]"}], "==", "2"}],
                        ",",
                        RowBox[{
                          RowBox[{"y", "[", "0", "]"}], "==", "a"}]}],
                       "}"}], ",",
                    RowBox[{"{",
                      RowBox[{
                        RowBox[{"x", "[", "t", "]"}], ",",
                        RowBox[{"y", "[", "t", "]"}]}], "}"}], ",",
                    "t"}], "]"}], ",", " ",
                RowBox[{"{",
                  RowBox[{
                  "a", ",", " ", "0.5", ",", " ", "2.5", ",", "0.5"}],
                   "}"}]}], "]"}]}], ";"}],
        FormatType->StandardForm],
      StyleBox[" ",
        FormatType->StandardForm]}], "\[IndentingNewLine]",
    RowBox[{
      RowBox[{"{",
        RowBox[{
          RowBox[{"x", "[", "t", "]"}], ",", " ",
          RowBox[{"y", "[", "t", "]"}]}], "}"}], " ", "/.", " ",
      "severalSols"}], "\[IndentingNewLine]",
    RowBox[{"Evaluate", "[",
      RowBox[{
        RowBox[{"{",
          RowBox[{
            RowBox[{"x", "[", "t", "]"}], ",", " ",
            RowBox[{"y", "[", "t", "]"}]}], "}"}], " ", "/.", " ",
        "severalSols"}], "]"}]}], "Input"]

told me that to the naked eye, nothing changes.  I assume that if
ParametricPlot had the 'HoldFirst' attribute, then I would have used
the Evaluate method as well, and in fact, any function that has the
'HoldAll' or 'HoldFirst' attribute set, I should use Evaluate if I am
passing in something created by Table or Map?

As regards your response (b), I guess I wasn't clear.  I know that I
can set attributes for a pure function when I use the Function[] syntax
explicitly, but what if I wanted to set attributes for a pure function
such as #^2 & ?

For (f), I apologize for the lack of clarity.  Hopefully, a real
example of what I am attempting will help:

Cell[BoxData[{
    RowBox[{
      RowBox[{"eqnsToSolve", " ", "=", " ",
        RowBox[{"{",
          RowBox[{
            RowBox[{
              RowBox[{
                RowBox[{
                  SubscriptBox["x", "1"], "'"}], "[", "t", "]"}],
              "\[Equal]",
              RowBox[{
                SubscriptBox["\[Lambda]", "1"], " ",
                RowBox[{
                  SubscriptBox["x", "1"], "[", "t", "]"}]}]}], ",",
            RowBox[{
              RowBox[{
                RowBox[{
                  SubscriptBox["x", "2"], "'"}], "[", "t", "]"}],
              "\[Equal]",
              RowBox[{
                SubscriptBox["\[Lambda]", "2"], " ",
                RowBox[{
                  SubscriptBox["x", "2"], "[", "t", "]"}]}]}]}],
          "}"}]}], ";"}], "\[IndentingNewLine]",
    RowBox[{
      RowBox[{"severalSols", " ", "=", " ",
        RowBox[{"DSolve", "[",
          RowBox[{"eqnsToSolve", ",",
            RowBox[{"{",
              RowBox[{
                RowBox[{
                  SubscriptBox["x", "1"], "[", "t", "]"}], ",",
                RowBox[{
                  SubscriptBox["x", "2"], "[", "t", "]"}]}], "}"}],
            ",", "t", ",", " ",
            RowBox[{"GeneratedParameters", "\[Rule]",
              RowBox[{"(",
                RowBox[{
                  SubscriptBox["x", "0"], " ", "&"}], ")"}]}]}],
          "]"}]}], "\[IndentingNewLine]",
      RowBox[{"(*", " ",
        RowBox[{
          RowBox[{
          "this", " ", "is", " ", "what", " ", "I", " ", "poorly",
            " ", "explained", " ",
            RowBox[{"before", ".", "  ", "I"}], " ", "want", " ",
            "to", " ", "try", " ", "to", " ", "match", " ",
            SubscriptBox["x", "j"], " ", "for", " ", "any", " ", "j",
            " ", "in", " ",
            RowBox[{
              RowBox[{"severalSols", "[",
                RowBox[{"[", "1", "]"}], "]"}], ".", "  ",
              "However"}]}], ",", " ",
          RowBox[{"it", " ",
            RowBox[{"didn", "'"}], "t", " ", "work"}], ",", " ",
          RowBox[{
          "and", " ", "I", " ", "resorted", " ", "to", " ", "what",
            " ", "is", " ", "in", " ", "the", " ", "line", " ",
            "after", " ", "this", " ", "attempt"}]}], " ",
        "*)"}]}], "\[IndentingNewLine]",
    RowBox[{
      SubscriptBox["x", "_"], " ", "/.",
      RowBox[{"severalSols", "[",
        RowBox[{"[", "1", "]"}], "]"}]}], "\[IndentingNewLine]",
    RowBox[{
      RowBox[{"completeSols", " ", "=", " ",
        RowBox[{
          RowBox[{"{",
            RowBox[{
              RowBox[{
                RowBox[{
                  SubscriptBox["x", "j"], "[", "t", "]"}], "/.",
                RowBox[{"j", "\[Rule]", "1"}]}], ",",
              RowBox[{
                RowBox[{
                  SubscriptBox["x", "j"], "[", "t", "]"}], "/.",
                RowBox[{"j", "\[Rule]", "2"}]}]}], "}"}], "/.",
          RowBox[{"severalSols", "[",
            RowBox[{"[", "1", "]"}], "]"}]}]}],
      ";"}], "\[IndentingNewLine]",
    RowBox[{
      RowBox[{"\[Phi]", "[",
        RowBox[{"j_Integer", ",",
          RowBox[{"tt_Integer", "|", "tt_Real"}], ",", " ", "x0_"}],
        "]"}], " ", ":=", " ",
      RowBox[{
        RowBox[{"completeSols", "[",
          RowBox[{"[", "j", "]"}], "]"}], " ", "/.", " ",
        RowBox[{"{",
          RowBox[{
            RowBox[{"t", "\[Rule]", "tt"}], ",",
            RowBox[{
              SubscriptBox["x", "0"], "\[Rule]", "x0"}]}], " ",
          "}"}]}]}], "\[IndentingNewLine]",
    RowBox[{
      RowBox[{"h", "[",
        RowBox[{"x_Integer", "|", "x_Real"}], "]"}], " ", ":=", " ",
      RowBox[{"\[Piecewise]", GridBox[{
            {
              SuperscriptBox["x",
                FractionBox[
                  SubscriptBox["\[Lambda]", "2"],
                  SubscriptBox["\[Lambda]", "1"]]],
              RowBox[{"x", "\[GreaterEqual]", "0"}]},
            {
              RowBox[{"-",
                SuperscriptBox[
                  RowBox[{"Abs", "[", "x", "]"}],
                  FractionBox[
                    SubscriptBox["\[Lambda]", "2"],
                    SubscriptBox["\[Lambda]", "1"]]]}],
              RowBox[{"x", "<", "0"}]}
            }]}]}]}], "Input"]

Finally, as regards your answer (g)-2, if Print returns 'Null', and I
successfully evaluated the same code without the 'False' at the end of
the sample, I still don't understand what use the 'False' at the end
is?

Thanks again,

Matt


  • Prev by Date: Re: Wick like theorem and "symbolic" compilation
  • Next by Date: Re: Re: Skipping Elements in Sum
  • Previous by thread: Re: Sundry Questions
  • Next by thread: Re: Sundry Questions