Solving a max() Function with Binary Operators

In summary, the conversation is about expressing the function f(x,y,z) = \frac{max(0, (x-y) )}{z} using standard binary operators and without the use of if or else statements. Possible solutions suggested include using the absolute value function or converting to polar or complex numbers, but the best solution is still being sought.
  • #1
Barking_Mad
11
0
Hey i was wondering if someone could help me express this using standard binary operators.

[tex]f(x,y,z)=\frac{max(0, (x-y) )}{z}[/tex]

i.e. Eliminate the max() function and write it using proper math.

EDIT: max(a,b) simply chooses the largest value of the two variables.
 
Mathematics news on Phys.org
  • #2
What you have there already is valid, but you can use this one if you like it better

Also, note that z cannot be 0 (the first line is just declaring the domain and codomain of f)

[tex]
f: \mathbb{R} \times \mathbb{R} \times \mathbb{R} \backslash \{0\} \to \mathbb{R}[/tex]
[tex]

f(x,y,z) = \left\{
\begin{array} {l l}
\displaystyle{\frac{x-y}{z}} & \text{if} \ x > y \\
0 & \text{else}
\right.
[/tex]
 
  • #3
hmm yeah, that's not exactly what i was looking for, apologies for lack of clarity.

Im looking for an algebraic expresion of that function, as a fraction or something similar, without the need to use if or else. If that is possible, maybe it isnt.
 
  • #4
How about

[tex]\frac{|x-y|+(x-y)}{2z}[/tex]
 
  • #5
ok, now i need to express that without the absolute function, or using polar or complex numbers. Could take me all week...
 
  • #6
For the absolute value you could use [tex]\sqrt {(x - y)^2}[/tex] (I smell a computer nearby), but it looks like on overshoot to me.
 

What is a max() function?

A max() function is a mathematical function that takes in a set of numbers and returns the largest value. It is commonly used in programming to find the highest value in a list or array of numbers.

How do binary operators work in a max() function?

In a max() function, binary operators are used to compare two values and determine which one is larger. The most commonly used binary operator for finding the maximum value is the greater than (>) operator.

Can a max() function be used with multiple binary operators?

Yes, a max() function can be used with multiple binary operators to compare more than two values. For example, you can use the greater than (>) operator to compare three values and find the largest of the three.

What are some common mistakes when using binary operators in a max() function?

One common mistake is using the wrong operator, such as using the equal to (==) operator instead of the greater than (>) operator. Another mistake is not properly setting up the syntax for the binary operator, which can result in incorrect comparisons.

Are there any limitations to using binary operators in a max() function?

One limitation is that binary operators can only compare two values at a time. This means that if you have a large set of numbers, you may need to use multiple binary operators to find the maximum value. Additionally, binary operators can only compare numbers and not other data types.

Similar threads

  • General Math
Replies
2
Views
723
  • General Math
Replies
3
Views
1K
Replies
7
Views
822
  • Programming and Computer Science
Replies
3
Views
355
Replies
1
Views
1K
Replies
17
Views
2K
  • Precalculus Mathematics Homework Help
Replies
3
Views
818
  • General Math
Replies
13
Views
2K
  • General Math
Replies
17
Views
2K
Replies
2
Views
248
Back
Top