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
Paul Ferraro
10/14/99 3:33pm

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 haven't tried it, but I believe you could also try to use the Condition function (/;). Assuming that ''not equal to'' is the Mathematica symbol for the same idea (since I don't know how to produce the symbol in Netscape),

f[x_,y_ /; x ''not equal to'' y] := g[x,y]
f[x_,y_ /; x == y] := h[x]

Paul Ferraro
Cornell University

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