Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Define function with conditions' topicStudent Support Forum > General > Archives > "Define function with conditions"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Carl Woll
09/15/99 7:18pm

>
>
> I would like to define a function with two variables, as follow:
>
> f[x_,y_]:= g[x,y] if x not equal to y
> f[x_,y_]:= h[x] if y=x
>
> I don't know how to do this, and would appreciate any help.
> Thanks in advance
> Robin

Robin,

One idea is to use multiple definitions, as in

f[x_,x_]:=h[x]
f[x_,y_]:=g[x,y]

Carl Woll
Physics Dept
U of Washington

URL: ,

Subject (listing for 'Define function with conditions')
Author Date Posted
Define function with conditions Robin Quartier 09/15/99 12:22pm
Re: Define function with conditions Carl Woll 09/15/99 7:18pm
Re: Define function with conditions Paul Ferraro 10/14/99 3:33pm
Re: Define function with conditions Randy Silvers 10/20/99 7:21pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic