Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*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 2001

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

Search the Archive

RE: Simple questions about Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31892] RE: [mg31888] Simple questions about Mathematica
  • From: "David Park" <djmp at earthlink.net>
  • Date: Mon, 10 Dec 2001 06:14:31 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Stephen,

Trying to match square roots with replacement rules is always a bit of a
problem because Mathematica represents them by Power[expr,1/2] in the
numerator and Power[expr,-1/2] in the denominator. So it is better to use
Power to begin with. So this works...

expr = 2/(3*Sqrt[a^2 + b^2]) + (1 - Sqrt[a^2 + b^2])^2 +
   E^(-a + Sqrt[a^2 + b^2]);

expr /. Power[a^2 + b^2, n : (-1/2 | 1/2)] -> Power[x, n]
E^(-a + Sqrt[x]) + (1 - Sqrt[x])^2 + 2/(3*Sqrt[x])

where I have used the Alternatives pattern matching construction for n. The
replacement rule could also be written as:

expr /. (a^2 + b^2)^n:(1/2 | -(1/2)) -> x^n

As for running Mathematica in a "batch" mode, I always use Mathematica
interactively, and I think that is the best way to use it. But I never have
occasion to run really time consuming problems. Perhaps someone else will
give you advice on that.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


> -----Original Message-----
> From: Stephen Gray [mailto:stevebg at adelphia.net]
To: mathgroup at smc.vnet.net
> Sent: Sunday, December 09, 2001 6:07 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg31892] [mg31888] Simple questions about Mathematica
>
>
> 1. Suppose I solve some equations and get a complicated
> expression containing multiple identical elements such as
> sqrt(a^2+b^2). To make the expression smaller, clearer, and
> easier to deal with, I want to substitute say R=sqrt(a^2+b^2)
> everywhere in the main expression and have R available as
> a symbol from then on. I see nothing in Help or anywhere
> else about how to do this. But it's such a standard thing to
> do that there must be an easy answer.
>
> 2. I'm not sure how a "batch" file is suppposed to be
> prepared and fed to Mathematica. That is, I want to
> prepare a bunch of operations and variables in advance
> and feed it in, preferably having mathematica give me
> line-by-line output as it would if I were typing each line
> in  one by one.
>
>     As a new user I really need answers to these questions.
> Thanks in advance for any information.
>



  • Prev by Date: Re: Re: scope all wrong? in Mathematica 4.1
  • Next by Date: Re: Re: scope all wrong? in Mathematica 4.1
  • Previous by thread: Re: Simple questions about Mathematica
  • Next by thread: Re: Simple questions about Mathematica