Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13817 > unrolled thread
| Started by | Rahul Chakraborty <rahul.6sept@gmail.com> |
|---|---|
| First post | 2013-03-12 04:34 +0000 |
| Last post | 2013-03-13 08:18 +0000 |
| Articles | 8 — 8 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Query regarding Function Rahul Chakraborty <rahul.6sept@gmail.com> - 2013-03-12 04:34 +0000
Re: Query regarding Function Oliver Roese <Oliver.Roese@FernUni-Hagen.de> - 2013-03-13 08:17 +0000
Re: Query regarding Function David Bailey <dave@removedbailey.co.uk> - 2013-03-13 08:18 +0000
Re: Query regarding Function Peter Pein <petsie@dordos.net> - 2013-03-13 08:17 +0000
Re: Query regarding Function svkeeley@aol.com - 2013-03-13 08:18 +0000
Re: Query regarding Function Richard Fateman <fateman@cs.berkeley.edu> - 2013-03-13 08:18 +0000
Re: Query regarding Function "Dr. Wolfgang Hintze" <weh@snafu.de> - 2013-03-13 08:17 +0000
Re: Query regarding Function Frank K <fkampas@gmail.com> - 2013-03-13 08:18 +0000
| From | Rahul Chakraborty <rahul.6sept@gmail.com> |
|---|---|
| Date | 2013-03-12 04:34 +0000 |
| Subject | Query regarding Function |
| Message-ID | <khmb84$ngv$1@smc.vnet.net> |
Dear all,
Case1: In the following code
Clear[f,x,y]
g=Function[{x,y},x^2+2xy][b,a]
The output is found to be b^2+2 xy
Case2: But for the code
Clear[f,x,y]
g=Function[{x,y},x^2+2y][b,a]
The output is 2 a+b^2
Hence my query is why in case 1 x*y is not replaced by b and a whereas in case 2 it got replaced ?
Regards,
rc
[toc] | [next] | [standalone]
| From | Oliver Roese <Oliver.Roese@FernUni-Hagen.de> |
|---|---|
| Date | 2013-03-13 08:17 +0000 |
| Message-ID | <khpcnh$md6$1@smc.vnet.net> |
| In reply to | #13817 |
Am 12.03.2013 05:34, schrieb Rahul Chakraborty:
> Dear all,
>
> Case1: In the following code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2xy][b,a]
>
> The output is found to be b^2+2 xy
>
> Case2: But for the code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2y][b,a]
>
> The output is 2 a+b^2
>
> Hence my query is why in case 1 x*y is not replaced by b and a whereas in case 2 it got replaced ?
>
> Regards,
> rc
>
"xy" is parsed as a single symbol in the former case. Try to put a space
between both variables:
Clear[f, x, y]
g = Function[{x, y}, x^2 + 2 x y][b, a]
My output is: 2 a b + b^2
Best regards
Oliver
[toc] | [prev] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2013-03-13 08:18 +0000 |
| Message-ID | <khpcp1$me6$1@smc.vnet.net> |
| In reply to | #13817 |
[This thread is now closed. There have been enough answers. - Moderator]
On 12/03/2013 04:34, Rahul Chakraborty wrote:
> Dear all,
>
> Case1: In the following code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2xy][b,a]
>
> The output is found to be b^2+2 xy
>
> Case2: But for the code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2y][b,a]
>
> The output is 2 a+b^2
>
> Hence my query is why in case 1 x*y is not replaced by b and a whereas in case 2 it got replaced ?
>
> Regards,
> rc
>
Variable names in Mathemnatica can be more than one character long -
remember that computer algebra can require a lot of variables! Thus xy
is a quite distinct variable - space the two characters out to get a
product: x y .
Note that it is always useful to examine dubious expressions using
FullForm (possibly with Hold to prevent evaluation) to determine their
true structure. This resolved a host of puzzles:
In[1]:= x y //FullForm
Out[1]//FullForm= Times[x,y]
In[2]:= xy //FullForm
Out[2]//FullForm= xy
In[3]:= x*y //FullForm
Out[3]//FullForm= Times[x,y]
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2013-03-13 08:17 +0000 |
| Message-ID | <khpcnb$m9n$1@smc.vnet.net> |
| In reply to | #13817 |
Am 12.03.2013 05:34, schrieb Rahul Chakraborty:
> Dear all,
>
> Case1: In the following code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2xy][b,a]
>
> The output is found to be b^2+2 xy
>
> Case2: But for the code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2y][b,a]
>
> The output is 2 a+b^2
>
> Hence my query is why in case 1 x*y is not replaced by b and a whereas in case 2 it got replaced ?
>
> Regards,
> rc
>
Hi rc,
this occurs because you used a variable named "xy", not the product
"x*y" (or a space in place of the asterisk ("x y")).
Peter
[toc] | [prev] | [next] | [standalone]
| From | svkeeley@aol.com |
|---|---|
| Date | 2013-03-13 08:18 +0000 |
| Message-ID | <khpcos$me4$1@smc.vnet.net> |
| In reply to | #13817 |
In case one x*y didn't get replaced because it wasn't there; instead the variable xy was. Put a space between the x and the y:
In[3]:= Clear[f, x, y]
g = Function[{x, y}, x^2 + 2 x y][b, a]
Out[4]= 2 a b+b^2
[toc] | [prev] | [next] | [standalone]
| From | Richard Fateman <fateman@cs.berkeley.edu> |
|---|---|
| Date | 2013-03-13 08:18 +0000 |
| Message-ID | <khpco6$mdl$1@smc.vnet.net> |
| In reply to | #13817 |
On 3/11/2013 9:34 PM, Rahul Chakraborty wrote:
> Dear all,
>
> Case1: In the following code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2xy][b,a]
>
> The output is found to be b^2+2 xy
>
> Case2: But for the code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2y][b,a]
>
> The output is 2 a+b^2
>
> Hence my query is why in case 1 x*y is not replaced by b and a whereas in case 2 it got replaced ?
>
> Regards,
> rc
>
try using x^2+2*x*y
xy is not the same as x*y
[toc] | [prev] | [next] | [standalone]
| From | "Dr. Wolfgang Hintze" <weh@snafu.de> |
|---|---|
| Date | 2013-03-13 08:17 +0000 |
| Message-ID | <khpcnm$md9$1@smc.vnet.net> |
| In reply to | #13817 |
On 12 Mrz., 05:34, Rahul Chakraborty <rahul.6s...@gmail.com> wrote:
> Dear all,
>
> Case1: In the following code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2xy][b,a]
>
> The output is found to be b^2+2 xy
>
> Case2: But for the code
>
> Clear[f,x,y]
> g=Function[{x,y},x^2+2y][b,a]
>
> The output is 2 a+b^2
>
> Hence my query is why in case 1 x*y is not replaced by b and a whereas=
in case 2 it got replaced ?
>
> Regards,
> rc
It's a simple typo:
You must separate x from y in xy by * or space.
Regards,
Wolfgang
[toc] | [prev] | [next] | [standalone]
| From | Frank K <fkampas@gmail.com> |
|---|---|
| Date | 2013-03-13 08:18 +0000 |
| Message-ID | <khpcoc$mdp$1@smc.vnet.net> |
| In reply to | #13817 |
On Tuesday, March 12, 2013 12:34:12 AM UTC-4, Rahul Chakraborty wrote:
> Dear all,
>
>
>
> Case1: In the following code
>
>
>
> Clear[f,x,y]
>
> g=Function[{x,y},x^2+2xy][b,a]
>
>
>
> The output is found to be b^2+2 xy
>
>
>
> Case2: But for the code
>
>
>
> Clear[f,x,y]
>
> g=Function[{x,y},x^2+2y][b,a]
>
>
>
> The output is 2 a+b^2
>
>
>
> Hence my query is why in case 1 x*y is not replaced by b and a whereas in case 2 it got replaced ?
>
>
>
> Regards,
>
> rc
You need a space between the x and the y. What you have looks like a symbol xy, not x*y.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web