Sundry Questions

*To*: mathgroup at smc.vnet.net*Subject*: [mg61086] Sundry Questions*From*: "Matt" <anonmous69 at netscape.net>*Date*: Sun, 9 Oct 2005 01:36:40 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Hello, First off, what follows are multiple questions that I have accumulated from using Mathematica over the past couple of weeks. I figured it would be less annoying to post in batches rather than a new question every day. If I am incorrect in this, please let me know. Anyway, I appreciate any and all help to be offered. Each new question will be delimited by 'Question:'. Question: Problem producing output as shown in "Differential Equations with Mathematica" by Abell and Braselton on page 435. Before embarking on any of the following, I loaded the PlotField package via: <<Graphics`PlotField` What didn't work: pvf = PlotVectorField[{2 y, -1/4 x}, {x, -6, 6}, {y, -3, 3}, DisplayFunction->Identity]; severalSols = Map[DSolve[{x'[t]==2 y[t],y'[t]==-1/4 x[t], x[0]==2,y[0]==#},{x[t],y[t]},t]&,{0.5,1,1.5,2,2.5}]; (* I also tried Table instead of Map (which didn't work either) as follows: severalSols = Table[DSolve[{x'[t]==2 y[t],y'[t]==-1/4 x[t],x[0]==2, y[0]==a},{x[t],y[t]},t], {a, 0.5, 2.5,0.5}]; *) p3 = ParametricPlot[{x[t],y[t]}/.severalSols, {t,0,2Sqrt[2]Pi}, Compiled->False,DisplayFunction->Identity]; Show[pvf,p3, PlotRange->{{-6,6},{-3,3}},AspectRatio->Automatic,DisplayFunction->$DisplayFunction,Axes->Automatic,AxesLabel->{"x","y"}]; The error I got was this: ParametricPlot::pptr: {x[t], y[t]} /. severalSols does not evaluate to a pair of real numbers at t = 8.894660536853585`*^-9. Which, when I looked at what severalSols evaluates to by itself, made sense to me. What did work: pvf = PlotVectorField[{2 y, -1/4 x}, {x, -6, 6}, {y, -3, 3}, DisplayFunction->Identity]; severalSols = Table[DSolve[{x'[t]==2 y[t],y'[t]==-1/4 x[t],x[0]==2, y[0]==a},{x[t],y[t]},t], {a, 0.5, 2.5,0.5}]; parPlots = Table[ParametricPlot[{x[t], y[t]} /. severalSols[[a,1]], {t,0,2Sqrt[2]Pi}, Compiled->False, DisplayFunction->Identity], {a,1,5,1}]; Show[pvf,parPlots, PlotRange->{{-6,6},{-3,3}},AspectRatio->Automatic,DisplayFunction->$DisplayFunction,Axes->Automatic,AxesLabel->{"x","y"}]; My question is this: How would I have made the failed attempt work without introducing the intermediate step of creating a new table of the graphics themselves? Question: How do I set attributes for a pure function using the & approach as opposed to the Function[] approach? Question: Selecting a word from the help, pressing F1, then navigating back to original page, starts you off back at the beginning, not where you were. Is there a setting to change this behaviour to such that when you navigate back, your view of the previous page is where it was? (Much like a web page works for example). Also, if I click on a function name, press F1, then navigate from the entry for Prepend by clicking on something like See Section 1.8.6, if I click the navigate backwards button twice, I do not go back to the original page that I started from. Question: I saw 'SameTest' used in Mathematica Navigator 2, but I can't find it referenced in the help of Mathematica 5.1. It does appear on the www.wolfram.com site under help for version 3.x. Is SameTest deprecated? Question: Is there a way to get GeneratedParameters to issue the same constant of integration instead of the form x0[1], x0[2], etc.? (e.g. just plain x0 for each and every invocation where I specify GeneratedParameters) Question: When dealing with subscripts, how do I do pattern matching? e.g. I have a list of rules such as solsList = {x1[t]->something, x2[t]->somethingElse} where the '1' and the '2' are actually subscripts, I can use x1[t] /. solsList to get back x1 or x2[t] /. solsList to get back x2 (where, again, '1' and '2' are subscripts). However, if I try to use Subscript[x,_] as the pattern, it never finds anything. Question: On page 612 of Michael Trott's "The Mathematica Guidebook for Programming" he uses the following construct to demonstrate the order in which the various parts of an expression would be tried in a pattern matching and replacing process with the following: rule = part_ \[RuleDelayed] (Null /; (Print["Trying : ",InputForm[part]]; False)) \!\(expression\ = \ \((xu\^xu\ + \ yu\^yu)\)\^\(x0\^x0 + y0\^y0\) + \ 1\) expression /. rule (I'm not sure why, but if I try to grab all three of the above lines and paste them into Mathematica, the middle line doesn't paste in properly. If I past each line in separately, then it works.) His example works just fine. Here is how I think it works: 'rule' contains a delayed rule with the following semantics: If the conditional evaluates to 'True', then 'Null' would be applied to the matching subexpression, which I assume would do nothing (or would the matching subexpression be replaced by 'Null'?) The conditional to be evaluated is (Print["Trying : ", InputForm[part]]; False), which if I understand the use of the parentheses in this context, will always evaluate to 'False' because of the '; False)' at the end. However, in the processing of the conditional, the Print statement will be executed with an argument of the string and the part that is currently being evaluated. Because of the way '/;' is defined ("a rule that applies only when a condition is satisfied"), I thought I'd investigate the behaviour of 'Print', i.e. what it returns. I assumed, because of the added 'False' in the conditional, that somehow, 'Print' returns 'True'. I'm not really sure how to evaluate what a function returns, but I figured I'd try something like this: True == Print["Trying : ", InputForm[x^2]] which returned True == Null I then assumed that Print returns Null, and decided to remove the 'False' part from the conditional, and it worked just as well as it did before: rule = part_ \[RuleDelayed] (Null /; (Print["Trying : ", InputForm[part]])) \!\(expression\ = \ \((xu\^xu\ + \ yu\^yu)\)\^\(x0\^x0 + y0\^y0\) + \ 1\) expression /. rule So, my question is this: What's the point of the 'False' in the conditional? and, on a minor note: Because the conditional will always evaluate to 'False' (or 'Null' if the 'False' clause is eliminated), could the 'Null' of the beforehand part (Null /; etc.) be replaced by anything we wanted? Thanks very much, Matt