http://learn.cemetech.net/index.php?title=TI-BASIC:Max&feed=atom&action=historyTI-BASIC:Max - Revision history2022-05-22T04:58:12ZRevision history for this page on the wikiMediaWiki 1.34.0http://learn.cemetech.net/index.php?title=TI-BASIC:Max&diff=946&oldid=prevMaintenance script: Initial automated import2016-02-24T18:26:42Z<p>Initial automated import</p>
<p><b>New page</b></p><div>{{Template:TI-BASIC:Command<br />
|picture=MAX.GIF<br />
|summary=Returns the maximum of two elements or of a list.<br />
|syntax=* for two numbers: max(''x'',''y'')<br />
* for a list: max(''list'')<br />
* comparing a number to each element of a list: max(''x'',''list'') or max(''list'',''x'')<br />
* pairwise comparing two lists: max(''list1'',''list2'')<br />
|location=Press:<br />
# MATH to access the [[TI-BASIC:Math|Math]] menu.<br />
# RIGHT to access the NUM submenu.<br />
# 7 to select max(, or use arrows.<br />
<br />
Alternatively, press:<br />
# 2nd LIST to access the list menu.<br />
# LEFT to access the MATH submenu.<br />
# 2 to select max(, or use arrows.<br />
|compatibility=TI-83/84/+/SE<br />
|size=1 byte<br />
}}<br />
<br />
max(''x'',''y'') returns the largest of the two numbers ''x'' and ''y''. max(''list'') returns the largest element of ''list''. max(''list1'',''list2'') returns the pairwise maxima of the two lists. max(''list1'',''x'') (equivalently, max(''x'',''list1'')) returns a list whose elements are the larger of ''x'' or the corresponding element of the original list.<br />
<br />
max(2,3)<br />
3<br />
max({2,3,4})<br />
4<br />
max({1,3},{4,2})<br />
{4 3}<br />
max({1,3},2)<br />
{2 3}<br />
<br />
Unlike comparison operators such as < and >, max( can also compare complex numbers. To do this, both arguments must be complex -- either complex numbers or complex lists: max(2,''i'') will throw an error even though max(2+0''i'',''i'') won't. In the case of complex numbers, the number with the largest absolute value will be returned. When the two numbers have the same absolute value, the first one will be returned: max(''i'',-''i'') returns ''i'' and max(-''i'',''i'') returns -''i''.<br />
<br />
= Advanced Uses =<br />
<br />
max( can be used in Boolean comparisons to see if at least one of a list is 1 (true) -- useful because commands like [[TI-BASIC:If|If]] or [[TI-BASIC:While|While]] only deal with numbers, and not lists, but comparisons like L1=L2 return a list of values. In general, the behavior you want varies, and you will use the [[TI-BASIC:Min|Min(]] function or the max( function accordingly.<br />
<br />
Using max( will give you a lenient test -- if any one element of the list is 1 (true), then the max( of the list is true -- this is equivalent to putting an 'or' in between every element. For example, this tests if K is equal to any of 24, 25, 26, or 34 (the [[TI-BASIC:Getkey|GetKey]] arrow key values):<br />
<br />
:If max(K={24,25,26,34<br />
:Disp "ARROW KEY<br />
<br />
<br />
To get the element of a real list with the greatest absolute value, use imag(max(iAns.<br />
<br />
= Error Conditions =<br />
<br />
* '''[[TI-BASIC:Errors#datatype|ERR:DATA TYPE]]''' is thrown when comparing a real and a complex number. This can be avoided by adding +0''i'' to the real number (or ''i^4'' right after it, for those who are familiar with complex numbers)<br />
* '''[[TI-BASIC:Errors#dimmismatch|ERR:DIM MISMATCH]]''' is thrown, when using max( with two lists, if they have different dimensions.<br />
<br />
= Related Commands =<br />
<br />
* [[TI-BASIC:Min|Min(]]<br />
* [[TI-BASIC:Sum|Sum(]]<br />
* [[TI-BASIC:Prod|Prod(]][[Category:TI-BASIC]]<br />
[[Category:TIBD]]</div>Maintenance script