< Back to Snippets

Perfect Zero

Use the various rationalize snippets already posted to try to turn the results of MathZero into a perfect number. This can replace the standard MathZero in the toolbar if you so choose. Unfortunately doesn't play nice with the other solver functions the way the stock MathZero does.


<function ID="perfectZero" label="zero" parameters="3">
  <MathZero.Action/>

  <StackBox.UpArrow/>
  <StackBox.RightArrow/>
  <StackBox.Enter/>
  <StackBox.ApplyConsole/>
  <StackBox.Digit1/>
  <StackBox.Digit0/>
  <StackBox.Digit0/>

  <function ref="rationalize"/>
  <MathWhere.Action/>
  <ifX isZero="true">
    <StackBox.Explode/>
    <StackBox.Roll4Down/>
    <StackBox.Clear/>
    <StackBox.Clear/>
    <StackBox.Clear/>
  </ifX>
  <else>
    <StackBox.Explode/>
    <StackBox.Roll3Down/>
    <StackBox.Clear/>
    <StackBox.Clear/>
    <StackBox.Explode/>

    <function ref="rationalizePi"/>
    <MathWhere.Action/>
    <ifX isZero="true">
      <StackBox.Explode/>
      <StackBox.Roll4Down/>
      <StackBox.Clear/>
      <StackBox.Clear/>
      <StackBox.Clear/>
    </ifX>
    <else>
      <StackBox.Explode/>
      <StackBox.Roll3Down/>
      <StackBox.Clear/>
      <StackBox.Clear/>
      <StackBox.Explode/>
        
      <function ref="rationalizeSqrt"/>
      <MathWhere.Action/>
      <ifX isZero="true">
        <StackBox.Explode/>
        <StackBox.Roll4Down/>
        <StackBox.Clear/>
        <StackBox.Clear/>
        <StackBox.Clear/>
      </ifX>
      <else>
        <StackBox.Explode/>
        <StackBox.Roll3Down/>
        <StackBox.Clear/>
        <StackBox.Clear/>
        <StackBox.Explode/>

        <function ref="rationalizeLn"/>
        <MathWhere.Action/>
        <ifX isZero="true">
          <StackBox.Explode/>
          <StackBox.Roll4Down/>
          <StackBox.Clear/>
          <StackBox.Clear/>
          <StackBox.Clear/>
        </ifX>
        <else>
          <StackBox.Explode/>
          <StackBox.Roll3Down/>
          <StackBox.Clear/>
          <StackBox.Clear/>
          <StackBox.Explode/>

          <function ref="rationalizeExp"/>
          <MathWhere.Action/>
          <ifX isZero="true">
            <StackBox.Explode/>
            <StackBox.Roll4Down/>
            <StackBox.Clear/>
            <StackBox.Clear/>
            <StackBox.Clear/>
          </ifX>
          <else>
            <StackBox.Clear/>
          </else>
        </else>
      </else>
    </else>
  </else>
</function>