Mathematica 9 is now available

If

If[condition, t, f] gives t if condition evaluates to True, and f if it evaluates to False.
If[condition, t, f, u] gives u if condition evaluates to neither True nor False.

If evaluates only the argument determined by the value of the condition.
If[condition, t, f] is left unevaluated if condition evaluates to neither True nor False.
If[condition, t] gives Null if condition evaluates to False.
• See also:
Which, While.

Examples

Using InstantCalculators

Here are the InstantCalculators for the If function. Enter the parameters for your calculation and click Calculate to see the result.

Entering Commands Directly

You can paste a template for this command via the Text Input button on the If Function Controller.

The test gives False, so y is returned.

The test gives neither True nor False, so neither branch is evaluated.

If there is a fourth argument to If, it is used when the test does not yield True or False.



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.