       Re: Why can't I solve this SIMPLE problem?

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg1225] Re: Why can't I solve this SIMPLE problem?
• From: bob Hanlon <hanlon at pafosu2.hq.af.mil>
• Date: Fri, 26 May 1995 02:59:56 -0400

```In Mathematica if you define R as Sqrt[x^2 + y^2] it will always make that
substitution for R.  Consequently, you must avoid the direct assignment.
Try this:

z /. Solve[{R == Sqrt[x^2 + y^2], z == D[Sqrt[x^2 + y^2], x]}, z, y]

this will return x/R.  You can also write this as:

temp = Sqrt[x^2 + y^2];
z /. Solve[{R == temp, z == D[temp, x]}, z, y]

Bob Hanlon

---------- Forwarded message ----------
>From: fateman at peoplesparc.cs.berkeley.edu (Richard J Fateman)
>Subject: Re: Why can't I solve this SIMPLE problem?
> Date: 23 May 1995 18:17:36 GMT

In article <1995May23.152242.21102 at tron.bwi.wec.com>,
Mark W. Brown <MWBrown at AOL.com> wrote:
>I've been trying to solve a VERY simple symbolic problem, and
>none of the packages I have can do it.  I tried the symbolic
>processor in MATHCAD (a subset of MAPLE, I believe) and the
>shareware program SYMBMATH.  Here's the problem:
>
>Given:  R = sqrt(x^2 + y^2)
>Find:  derivative dR/dx
>Solution Found:  dR/dx = x/sqrt(x^2+y^2)
>Desired Solution:  dR/dx = x/R
>
>Why don't these programs recognize that the square root in the
>denominator of the solution has been DEFINED as the variable R
>and substitute?  I have been unsuccessful using substitute because
>it apparently only works for simple variables (like x) and not
>expressions (like sqrt(x^2 + y^2).  This simple problem has become
>my test bench when I evaluate symbolic processors.
............

There are quite a number of system-independent symbolic algebra
systems bugs, and this one is a classic example.
By representing x/sqrt(x^2+y^2)  as  x* (x^2+y^2)^(-1/2), Maple
and some other systems fail to find any subexpression that
is equal to (x^2+y^2)^(1/2)   because there isn't one.

If you try substituting 1/R for 1/sqrt(x^2+y^2), it will likely
work as you expect on almost any system.

For at least 20 years, Macsyma has done this (by in effect substituting
for 1/r...).  automatically.

I do not know if one can coax other systems to "do the right thing"
automatically too.

I think it is not too expensive to check for this extra case most of the
time; and I think is unreasonable to require every user to understand
the internal representation of expressions in a computer algebra system
to get it to work.

Apparently other people disagree with me.

Here's macsyma:

(c1) r:sqrt(x^2+y^2)\$
(c2) diff(r,x);
x
(d2)                             -------------
2    2
sqrt(y  + x )
(c3) subst('r, sqrt(x^2+y^2),%);
x
(d3)                                   -
r
(c4) inpart(d2,2); /* pick out 2nd factor in internal representation */
1
(d4)                             -------------
2    2
sqrt(y  + x )
(c5) inpart(d4,2);/* pick out exponent [2nd part] of internal rep. */
1
(d5)                                  - -
2

There is another possible problem, and  that is that you are using
your system wrong, and not substituting "quote r"  for r's value,
and therefore trying to substitute sqrt(x^2+y^2) for sqrt(x^2+y^2)...
so nothing can change.

--
Richard J. Fateman
fateman at cs.berkeley.edu   510 642-1879

```

• Prev by Date: HELP: DXF files and Mma
• Next by Date: Re: Equating a variable and its value
• Previous by thread: Re: HELP: DXF files and Mma
• Next by thread: Re: Equating a variable and its value