0

The Octave interpreter evaluates this expression as false:

>> 2/3 + 1/6 == 5/6
ans = 0

cause

>> 2/3 + 1/6 - 5/6
ans =   -1.11022302462516e-16

This can be avoided with the rat (or rats) function, or casting the values, but the resulting expression lacks the clear formatting of the initial one:

>> all(rat(2/3 + 1/6) == rat(5/6))
ans =  1

>> single(2/3 + 1/6) == single(5/6)
ans =  1

When using Octave to teach kids arithmetic, 'dirty' translations of mathematical expressions are of no use.

Is there any global adjustment that could be done to evaluate as true the original expression?

nightcod3r
  • 752
  • 1
  • 7
  • 26
  • Don’t use Octave to teach kids arithmetic. Use software that does symbolic evaluation, maybe Mathematica? – Cris Luengo May 24 '18 at 16:15
  • @CrisLuengo Octave is FOSS, Mathematica is something most worldwide schools cannot afford. – nightcod3r May 24 '18 at 16:17
  • http://www.wolframalpha.com/input/?i=2%2F3+%2B+1%2F6+-+5%2F6 – Cris Luengo May 24 '18 at 16:22
  • There are also FOSS alternatives listed here: https://en.wikipedia.org/wiki/List_of_computer_algebra_systems – Cris Luengo May 24 '18 at 16:23
  • @CrisLuengo A reliable and individual Internet access (I'm afraid) is something many schools cannot afford either, at least so it is where I live. – nightcod3r May 24 '18 at 16:29
  • 1
    Sorry to hear that. From the list I linked, it seems that [SymPy](http://www.sympy.org/en/index.html) (Python module) could do what you want (it requires some setup, but that is trivial to automate), or [FriCAS](http://fricas.sourceforge.net/) (the more active fork of Axiom, which looks stale). Best of luck! – Cris Luengo May 24 '18 at 16:40

1 Answers1

0

Julia has a rational numbers type and is free. You don't need to use Octave symbolics. You can use a Jupyter notebook. Note that notebooks make great teaching tools. My professor used these to teach. Some examples are here.

2//3+1//6 

5//6