<![CDATA[Math Is Fun Forum / How would I write an if statement in an equation?]]> 2020-07-01T00:56:02Z FluxBB https://www.mathisfunforum.com/viewtopic.php?id=25745 <![CDATA[Re: How would I write an if statement in an equation?]]> Actually, piecewise functions are really just notation. Do you know how functions are usually viewed in modern mathematics?

]]>
https://www.mathisfunforum.com/profile.php?id=95904 2020-07-01T00:56:02Z https://www.mathisfunforum.com/viewtopic.php?pid=413893#p413893
<![CDATA[Re: How would I write an if statement in an equation?]]> bob bundy wrote:

hi pi_cubed

What do you want this for?  That might help me to provide an answer.

An 'equation' in algebra has a left hand expression and a right hand expression that evaluate to the same thing.  'If' isn't part of any equation I've met in algebra.  If … then does form part of the language of maths but not in the way you want (I think).

In logic there's a connective, =>  implies  that might fit the bill.  And you can form logic equations with implies in them. But the truth table for implies is simply described as TRUE unless the LHS is TRUE and the RHS FALSE.  I could probably construct a logic equivalent to your code if that would help.

Bob

I don't mean that it has to be an equation, it could be a type of function or a relationship. Piecewise functions should be enough.

]]>
https://www.mathisfunforum.com/profile.php?id=222180 2020-06-30T13:22:30Z https://www.mathisfunforum.com/viewtopic.php?pid=413883#p413883
<![CDATA[Re: How would I write an if statement in an equation?]]> Agnishom wrote:

is this related? https://www.mathsisfun.com/sets/functions-piecewise.html

Yes, that was exactly what I was talking about.

]]>
https://www.mathisfunforum.com/profile.php?id=222180 2020-06-30T13:14:45Z https://www.mathisfunforum.com/viewtopic.php?pid=413882#p413882
<![CDATA[Re: How would I write an if statement in an equation?]]> hi pi_cubed

What do you want this for?  That might help me to provide an answer.

An 'equation' in algebra has a left hand expression and a right hand expression that evaluate to the same thing.  'If' isn't part of any equation I've met in algebra.  If … then does form part of the language of maths but not in the way you want (I think).

In logic there's a connective, =>  implies  that might fit the bill.  And you can form logic equations with implies in them. But the truth table for implies is simply described as TRUE unless the LHS is TRUE and the RHS FALSE.  I could probably construct a logic equivalent to your code if that would help.

Bob

]]>
https://www.mathisfunforum.com/profile.php?id=67694 2020-06-30T07:32:19Z https://www.mathisfunforum.com/viewtopic.php?pid=413874#p413874
<![CDATA[Re: How would I write an if statement in an equation?]]> is this related? https://www.mathsisfun.com/sets/functions-piecewise.html

]]>
https://www.mathisfunforum.com/profile.php?id=95904 2020-06-30T01:48:55Z https://www.mathisfunforum.com/viewtopic.php?pid=413868#p413868
<![CDATA[How would I write an if statement in an equation?]]> I am wondering how you would write if statements, as shown below in Python, in an equation.

``````a = 1+2
b = 2+1
if a == b:
print('1+2=2+1')
elif not a == b:
print('1+2 does not equal 2+1 and this will never be printed')
else:
print('This will never be printed just like the above')``````

Does anyone know how to do this (maybe with the sign function)?

]]>
https://www.mathisfunforum.com/profile.php?id=222180 2020-06-29T13:19:25Z https://www.mathisfunforum.com/viewtopic.php?pid=413860#p413860