Difference between revisions of "If Command"

From GeoGebra Manual
Jump to: navigation, search
m (add link to Boolean Variables and Operations)
m (apply <tt></tt> formatting; apply Italic font)
Line 4: Line 4:
 
<div class="note">'''Note:'''  
 
<div class="note">'''Note:'''  
 
* The ''If'' command can be used to create conditional functions.  Such conditional functions may be used as arguments in any command that takes a function argument, such as [[Derivative Command|Derivative]], [[Integral Command|Integral]], and [[Intersect Command|Intersect]].
 
* The ''If'' command can be used to create conditional functions.  Such conditional functions may be used as arguments in any command that takes a function argument, such as [[Derivative Command|Derivative]], [[Integral Command|Integral]], and [[Intersect Command|Intersect]].
* Example: ''f(x) = If[x < 3, sin(x), x^2]'' yields a function that equals sin(x) for x < 3 and x<sup>2</sup> for x ≥ 3.
+
* Example: <tt>f(x) = If[x < 3, sin(x), x^2]</tt> yields a function that equals ''sin(x)'' for ''x < 3'' and ''x<sup>2</sup>'' for ''x ≥ 3''.
 
* See the section [[Boolean Variables and Operations]] for the symbols used in conditional statements.
 
* See the section [[Boolean Variables and Operations]] for the symbols used in conditional statements.
 
</div>
 
</div>

Revision as of 15:41, 3 November 2009

If[Condition, Object]
Yields a copy of the object if the condition evaluates to true, and an undefined object if it evaluates to false.
If[Condition, Object a, Object b]
Yields a copy of object a if the condition evaluates to true, and a copy of object b if it evaluates to false.
Note:
  • The If command can be used to create conditional functions. Such conditional functions may be used as arguments in any command that takes a function argument, such as Derivative, Integral, and Intersect.
  • Example: f(x) = If[x < 3, sin(x), x^2] yields a function that equals sin(x) for x < 3 and x2 for x ≥ 3.
  • See the section Boolean Variables and Operations for the symbols used in conditional statements.
© 2020 International GeoGebra Institute