       Re: Sundry Questions

• To: mathgroup at smc.vnet.net
• Subject: [mg61093] Re: Sundry Questions
• From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
• Date: Mon, 10 Oct 2005 02:39:54 -0400 (EDT)
• Organization: Uni Leipzig
• References: <diabu7\$ikb\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

I would like to have a single question per
posting, because it is also
more easy to you to follow the 1-20 soluions per
problem.

a) Use Evaluate[] in ParametricPlot[]
p3 = ParametricPlot[
Evaluate[{x[t], y[t]} /. severalSols], {t, 0,
2SqrtPi},
Compiled -> False, DisplayFunction -> Identity];
Show[pvf, p3,
PlotRange -> {{-6, 6}, {-3, 3}}, AspectRatio ->
Automatic,
DisplayFunction -> \$DisplayFunction, Axes ->
Automatic,
AxesLabel -> {"x", "y"}];

b) Function[] has a third argument for the
attributes

Function[{z}, z ** z, {Listable}] [{a, b, c, d}]

c) I prefer the usage messages of the kernel and
try to avoid the online-help notebooks.

d) here is why:

??SameTest

"SameTest is an option for functions like
FixedPoint that specifies the \
comparison function to apply to pairs of results
to determine whether they \
should be considered the same."

e) DSolve[x'''[t] == 0, x[t], t,
GeneratedParameters -> (nonsense &)]
f) the question is total unclear, because
MatchQ[#, Subscript[_, _]] & /@

{x, x1, Subscript[x, 1], y, Subscript[y, 2], y2}

work as expected and you should say what

| solsList = {x1[t]->something,
| x2[t]->somethingElse} where the '1' and the '2'
are actually
| subscripts"

mean because x1 is a symbol and has no subscript
and I would like to know what
an "actualy subscript" is.

g-1) copy & paste from a ASCII file work for
typesetted expressions only "cell wise",
the FrontEnd will not see that
"bla bla bla
\!\(x\^2\)"

should be interpretet as "bla bla bla" and x^2
it will assume that you wish to copy the ASCII
representation of it, and not the
interpreted mathematical expression for x^2 in the
second line.
The FrontEnd will only do that, when the string
or if you use Edit| Copy as | ...

g-2) since the rule
rule = part_ :> (Null /; (Print["Trying :",
InputForm[part]]; False))

should never match, the condition must be always
False, otherwise the rule would match and the
example can't show how the pattern matcher is
applyed to the subexpressions. But Condition[]
need to know whats to do when the test ist True,
even when this can't happen in thist case. You can
write anything instead of Null in the rule.

Regards

Jens

"Matt" <anonmous69 at netscape.net> schrieb im
Newsbeitrag news:diabu7\$ikb\$1 at smc.vnet.net...
| 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
| 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==2,y==#},{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==2,
| y==a},{x[t],y[t]},t], {a, 0.5, 2.5,0.5}];
| *)
| p3 = ParametricPlot[{x[t],y[t]}/.severalSols,
{t,0,2SqrtPi},
| 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==2,
| y==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,2SqrtPi}, 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, x0, 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
|

```

• Prev by Date: Re: Wick like theorem and "symbolic" compilation
• Next by Date: Re: simplifying rational expressions
• Previous by thread: Re: Sundry Questions
• Next by thread: Re: Sundry Questions