MathGroup Archive 2004

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

Search the Archive

Re: problem writing a simple equation--urgent!!!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50361] Re: [mg50359] problem writing a simple equation--urgent!!!
  • From: "David Park" <djmp at earthlink.net>
  • Date: Mon, 30 Aug 2004 01:34:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

You could use the following definition

u[i_, j_] := x[i] + 2 x[j]

u[2, 4]
x[2] + 2 x[4]

Or if you wanted to use different symbols for x...

Clear[u]
u[x_][i_, j_] := x[i] + 2x[j]

u[y][2, 4]
y[2] + 2 y[4]

I would tend to use SetDelayed, :=, rather than Set, =, for these
definitions.

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

From: aysegul [mailto:erkenays at yahoo.com]
To: mathgroup at smc.vnet.net

Hi all,
I have a problem about writing an equation in mathematica.
I am writing the following equation:
u[x_, y_] = x + 2*y
and when I write for example u[2,4] , it gives the result. But the
problem that I have is expressing this equation with parameters. That
is
u[x[1], x[2]] = x[1] + 2*x[2]
but when I ask u[2,4];
it gives u[2,4] result.It doesn't calculate.
So, how can I write this equation?
Thanks all.




  • Prev by Date: Re: problem writing a simple equation--urgent!!!
  • Next by Date: Re: problem writing a simple equation--urgent!!!
  • Previous by thread: Re: problem writing a simple equation--urgent!!!
  • Next by thread: Re: problem writing a simple equation--urgent!!!