Is there a ternary operator in mathConsidering math or computer scienceWhat is a good language to develop in...

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Avoiding unpacking an array when altering its dimension

Difference between 小吃 and 零食

Must a tritone substitution use a dominant seventh chord?

What is the wife of a henpecked husband called?

Is my plan for fixing my water heater leak bad?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Does music exist in Panem? And if so, what kinds of music?

How would we write a misogynistic character without offending people?

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

Is there a German word for “analytics”?

Why is working on the same position for more than 15 years not a red flag?

What do the pedals on grand pianos do?

If a druid in Wild Shape swallows a creature whole, then turns back to her normal form, what happens?

Accessing something inside the object when you don't know the key

chrony vs. systemd-timesyncd – What are the differences and use cases as NTP clients?

How can atoms be electrically neutral when there is a difference in the positions of the charges?

A "strange" unit radio astronomy

Is divide-by-zero a security vulnerability?

Easy code troubleshooting in wordpress

Hacker Rank: Array left rotation

Where is the fallacy here?

Why zero tolerance on nudity in space?

Did 5.25" floppies undergo a change in magnetic coating?



Is there a ternary operator in math


Considering math or computer scienceWhat is a good language to develop in for simple, yet customizable math programs?Translate Programming code to MathMath vocab: operator on $S$ and into $S =$?A set system generated by a closure operator?Evaluating math proofs by computeris all math beyond arithmetic just advanced arithmetic?Are there dictionaries in math?What is a good route for a math student to self study computer science systematically and efficiently?Multiplying two numbers using only the “left shift” operator













2












$begingroup$


Is there a math equivalent of the programming ternary operator?



a = b + c > 0 ? 1 : 2


The above meaning that if c is greater than 0 then a = b + 1 else a = b + 2.










share|cite|improve this question









$endgroup$












  • $begingroup$
    It probably depends on the form of the conditions and the results, but the example you gave can be expressed with the unit step $u(x)$ (with an appropriate definition at $x=1$): $a = u(b+c) + 1$
    $endgroup$
    – Alex
    52 mins ago












  • $begingroup$
    @Alex $a = b + 2 - u(c)$
    $endgroup$
    – eyeballfrog
    35 mins ago


















2












$begingroup$


Is there a math equivalent of the programming ternary operator?



a = b + c > 0 ? 1 : 2


The above meaning that if c is greater than 0 then a = b + 1 else a = b + 2.










share|cite|improve this question









$endgroup$












  • $begingroup$
    It probably depends on the form of the conditions and the results, but the example you gave can be expressed with the unit step $u(x)$ (with an appropriate definition at $x=1$): $a = u(b+c) + 1$
    $endgroup$
    – Alex
    52 mins ago












  • $begingroup$
    @Alex $a = b + 2 - u(c)$
    $endgroup$
    – eyeballfrog
    35 mins ago
















2












2








2


1



$begingroup$


Is there a math equivalent of the programming ternary operator?



a = b + c > 0 ? 1 : 2


The above meaning that if c is greater than 0 then a = b + 1 else a = b + 2.










share|cite|improve this question









$endgroup$




Is there a math equivalent of the programming ternary operator?



a = b + c > 0 ? 1 : 2


The above meaning that if c is greater than 0 then a = b + 1 else a = b + 2.







computer-science






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked 57 mins ago









dataphiledataphile

365




365












  • $begingroup$
    It probably depends on the form of the conditions and the results, but the example you gave can be expressed with the unit step $u(x)$ (with an appropriate definition at $x=1$): $a = u(b+c) + 1$
    $endgroup$
    – Alex
    52 mins ago












  • $begingroup$
    @Alex $a = b + 2 - u(c)$
    $endgroup$
    – eyeballfrog
    35 mins ago




















  • $begingroup$
    It probably depends on the form of the conditions and the results, but the example you gave can be expressed with the unit step $u(x)$ (with an appropriate definition at $x=1$): $a = u(b+c) + 1$
    $endgroup$
    – Alex
    52 mins ago












  • $begingroup$
    @Alex $a = b + 2 - u(c)$
    $endgroup$
    – eyeballfrog
    35 mins ago


















$begingroup$
It probably depends on the form of the conditions and the results, but the example you gave can be expressed with the unit step $u(x)$ (with an appropriate definition at $x=1$): $a = u(b+c) + 1$
$endgroup$
– Alex
52 mins ago






$begingroup$
It probably depends on the form of the conditions and the results, but the example you gave can be expressed with the unit step $u(x)$ (with an appropriate definition at $x=1$): $a = u(b+c) + 1$
$endgroup$
– Alex
52 mins ago














$begingroup$
@Alex $a = b + 2 - u(c)$
$endgroup$
– eyeballfrog
35 mins ago






$begingroup$
@Alex $a = b + 2 - u(c)$
$endgroup$
– eyeballfrog
35 mins ago












3 Answers
3






active

oldest

votes


















5












$begingroup$

Using the indicator function notation:$$a=b+1+1_{(-infty, 0]}(c)$$






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Indicator is definitely the way to go, since the conditional can define an arbitrary set.
    $endgroup$
    – eyeballfrog
    33 mins ago










  • $begingroup$
    Thank you, that is very elegant. I will definitely try out all of the answers as I often use this in various scenarios.
    $endgroup$
    – dataphile
    28 mins ago



















3












$begingroup$

In math, equations are written in piecewise form by having a curly brace enclose multiple lines; each one with a condition excepting the last which has "otherwise".



There are a few custom operators that also occasionally make an appearance. E.g. the Heavyside function mentioned by Alex, the Dirac function, and the cyclical operator $delta_{ijk}$ - all of which can be used to emulate conditional behaviour.






share|cite|improve this answer









$endgroup$





















    2












    $begingroup$

    This is not a ternary operator, it is a function of two variables. There is one operation that results in $a$. You can certainly define a function
    $$f(b,c)=begin {cases} b+1&c gt 0\
    b+2 & c le 0 end {cases}$$



    You can also define functions with any number of inputs you want, so you can define $f(a,b,c)=a(b+c^2)$, for example. This is a ternary function.






    share|cite|improve this answer









    $endgroup$













      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "69"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      noCode: true, onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3135798%2fis-there-a-ternary-operator-in-math%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5












      $begingroup$

      Using the indicator function notation:$$a=b+1+1_{(-infty, 0]}(c)$$






      share|cite|improve this answer









      $endgroup$













      • $begingroup$
        Indicator is definitely the way to go, since the conditional can define an arbitrary set.
        $endgroup$
        – eyeballfrog
        33 mins ago










      • $begingroup$
        Thank you, that is very elegant. I will definitely try out all of the answers as I often use this in various scenarios.
        $endgroup$
        – dataphile
        28 mins ago
















      5












      $begingroup$

      Using the indicator function notation:$$a=b+1+1_{(-infty, 0]}(c)$$






      share|cite|improve this answer









      $endgroup$













      • $begingroup$
        Indicator is definitely the way to go, since the conditional can define an arbitrary set.
        $endgroup$
        – eyeballfrog
        33 mins ago










      • $begingroup$
        Thank you, that is very elegant. I will definitely try out all of the answers as I often use this in various scenarios.
        $endgroup$
        – dataphile
        28 mins ago














      5












      5








      5





      $begingroup$

      Using the indicator function notation:$$a=b+1+1_{(-infty, 0]}(c)$$






      share|cite|improve this answer









      $endgroup$



      Using the indicator function notation:$$a=b+1+1_{(-infty, 0]}(c)$$







      share|cite|improve this answer












      share|cite|improve this answer



      share|cite|improve this answer










      answered 47 mins ago









      Siong Thye GohSiong Thye Goh

      102k1466118




      102k1466118












      • $begingroup$
        Indicator is definitely the way to go, since the conditional can define an arbitrary set.
        $endgroup$
        – eyeballfrog
        33 mins ago










      • $begingroup$
        Thank you, that is very elegant. I will definitely try out all of the answers as I often use this in various scenarios.
        $endgroup$
        – dataphile
        28 mins ago


















      • $begingroup$
        Indicator is definitely the way to go, since the conditional can define an arbitrary set.
        $endgroup$
        – eyeballfrog
        33 mins ago










      • $begingroup$
        Thank you, that is very elegant. I will definitely try out all of the answers as I often use this in various scenarios.
        $endgroup$
        – dataphile
        28 mins ago
















      $begingroup$
      Indicator is definitely the way to go, since the conditional can define an arbitrary set.
      $endgroup$
      – eyeballfrog
      33 mins ago




      $begingroup$
      Indicator is definitely the way to go, since the conditional can define an arbitrary set.
      $endgroup$
      – eyeballfrog
      33 mins ago












      $begingroup$
      Thank you, that is very elegant. I will definitely try out all of the answers as I often use this in various scenarios.
      $endgroup$
      – dataphile
      28 mins ago




      $begingroup$
      Thank you, that is very elegant. I will definitely try out all of the answers as I often use this in various scenarios.
      $endgroup$
      – dataphile
      28 mins ago











      3












      $begingroup$

      In math, equations are written in piecewise form by having a curly brace enclose multiple lines; each one with a condition excepting the last which has "otherwise".



      There are a few custom operators that also occasionally make an appearance. E.g. the Heavyside function mentioned by Alex, the Dirac function, and the cyclical operator $delta_{ijk}$ - all of which can be used to emulate conditional behaviour.






      share|cite|improve this answer









      $endgroup$


















        3












        $begingroup$

        In math, equations are written in piecewise form by having a curly brace enclose multiple lines; each one with a condition excepting the last which has "otherwise".



        There are a few custom operators that also occasionally make an appearance. E.g. the Heavyside function mentioned by Alex, the Dirac function, and the cyclical operator $delta_{ijk}$ - all of which can be used to emulate conditional behaviour.






        share|cite|improve this answer









        $endgroup$
















          3












          3








          3





          $begingroup$

          In math, equations are written in piecewise form by having a curly brace enclose multiple lines; each one with a condition excepting the last which has "otherwise".



          There are a few custom operators that also occasionally make an appearance. E.g. the Heavyside function mentioned by Alex, the Dirac function, and the cyclical operator $delta_{ijk}$ - all of which can be used to emulate conditional behaviour.






          share|cite|improve this answer









          $endgroup$



          In math, equations are written in piecewise form by having a curly brace enclose multiple lines; each one with a condition excepting the last which has "otherwise".



          There are a few custom operators that also occasionally make an appearance. E.g. the Heavyside function mentioned by Alex, the Dirac function, and the cyclical operator $delta_{ijk}$ - all of which can be used to emulate conditional behaviour.







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered 45 mins ago









          Paul ChildsPaul Childs

          3147




          3147























              2












              $begingroup$

              This is not a ternary operator, it is a function of two variables. There is one operation that results in $a$. You can certainly define a function
              $$f(b,c)=begin {cases} b+1&c gt 0\
              b+2 & c le 0 end {cases}$$



              You can also define functions with any number of inputs you want, so you can define $f(a,b,c)=a(b+c^2)$, for example. This is a ternary function.






              share|cite|improve this answer









              $endgroup$


















                2












                $begingroup$

                This is not a ternary operator, it is a function of two variables. There is one operation that results in $a$. You can certainly define a function
                $$f(b,c)=begin {cases} b+1&c gt 0\
                b+2 & c le 0 end {cases}$$



                You can also define functions with any number of inputs you want, so you can define $f(a,b,c)=a(b+c^2)$, for example. This is a ternary function.






                share|cite|improve this answer









                $endgroup$
















                  2












                  2








                  2





                  $begingroup$

                  This is not a ternary operator, it is a function of two variables. There is one operation that results in $a$. You can certainly define a function
                  $$f(b,c)=begin {cases} b+1&c gt 0\
                  b+2 & c le 0 end {cases}$$



                  You can also define functions with any number of inputs you want, so you can define $f(a,b,c)=a(b+c^2)$, for example. This is a ternary function.






                  share|cite|improve this answer









                  $endgroup$



                  This is not a ternary operator, it is a function of two variables. There is one operation that results in $a$. You can certainly define a function
                  $$f(b,c)=begin {cases} b+1&c gt 0\
                  b+2 & c le 0 end {cases}$$



                  You can also define functions with any number of inputs you want, so you can define $f(a,b,c)=a(b+c^2)$, for example. This is a ternary function.







                  share|cite|improve this answer












                  share|cite|improve this answer



                  share|cite|improve this answer










                  answered 40 mins ago









                  Ross MillikanRoss Millikan

                  298k23198371




                  298k23198371






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Mathematics Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3135798%2fis-there-a-ternary-operator-in-math%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

                      Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

                      Simple Scan not detecting my scanner (Brother DCP-7055W)Brother MFC-L2700DW printer can print, can't...