Today we’re pushing out the first public BETA of Acron RPN Calculator v3.0 for Android. Highlights for this release:

The most obvious change is that the ‘base’ button has been replaced with ‘mode’. This still contains options for switching to based-integer mode, but also now allows you to control the number format when in scientific mode. You can now choose whether you want to use the perfect number engine, on always want decimal answers; switch between normal, scientific, and engineering notations; switch between floating and fixed decimal places; and control the number of decimal places that will be displayed.

The primary focus of this release is more subtle. All of the UI primitives have been completely rewritten so that the entire user interface can be defined in XML. You can now load a new layout XML file and completely replace the UI with whatever you want. I’ll have more details on this in a follow-up post soon.

Having a fully customizable UI provided the freedom to create many new math functions without worrying about cluttering up the stock layout. There’s a bunch of new number theory and probability functions, including a complex gamma function. And the functionality suite I’m most proud of – a full set of numeric algorithms for finding function roots, derivatives, integrals, critical points, summations, and products. More on this in a follow-up post too. Again, none of these functions are available in the stock UI layout; you need a customized layout XML to expose them.

An unlimited number of memory registers, scientific constants, and unit conversions can be defined in your layout XML.

As usual, all new development in Acron RPN is done on Android. When Android is ready for BETA, the code is turned over so that iOS porting can begin. iOS porting tends to take about the same amount of time as working out any bugs discovered during the BETA process, then we try to do a coordinated finalized release.

UI layouts can be authored in XML, saved with the .acronrpn file extension, and loaded exactly like a saved stack .acronrpn file. Only the paid version of Acron RPN can change layouts. Here’s some useful downloads to get started:

Regardless of what your layout looks like, Acron RPN is always an entry-style RPN calculator with an unlimited stack. Layouts give you a lot of flexibility on how the app looks, but minimal flexibility in how it acts.

If there is a bug in your layout, Acron RPN will give an error message that should be sufficient to locate the problem. It will continue to use the previous layout until a new layout is successfully installed. Once a new layout is successfully installed, you will be forced to restart the app.

Layouts can be loaded from the stack -> open button, or launched directly from Google Drive, Downloads, a web browser, etc. Launching from Google Drive, etc. becomes necessary if your installed layout doesn’t expose an open button.

If something goes wrong, you can always get back to the stock layout by using “Clear Data” from Settings -> Apps -> Acron RPN Calculator -> Storage.

I just pushed an update of BETA 1 to the Play Store. There was an over-aggressive try/catch block that was preventing users from getting properly notified of bugs in their layouts. It should be much easier to write a layout now that you aren't doing it blindfolded.

Here's my first attempt (layout file attached; remove the ".txt" extension before use). It adds an extra row of keys above the numbers to give access to some of the new functions. The added keys are:

x - a variable for use in the functions below;

zero - finds the zero of a function of x;

integ - integrates a function of x between specified limits;

deriv - finds the numerical derivative of a function of x at a particular value of x;

sigma - sums a function of x over a specified range.

For example, to find a zero of \(\tan(x)-\sqrt{x}\):

Enter this function onto the stack. Do this by pressing the "x" key, then "tan", then "x", then "\(\sqrt{}\)", then "-" (minus). Note that the default value stored in x is zero.

Press "x" again; this tells the calculator which variable to solve for.

Enter a starting value for x: 1, for example.

Then press the "zero" key.

The answer appears in the stack.

The other functions work in a similar way, with the stack arguments being function, variable ("x" here, since I haven't put any others on the keyboard), and then one (zero, deriv) or two (integ, sigma) numerical values. These functions (and others) are described in the "Layout Documentation" linked to earlier in this thread.

I have many "classic" calculator apps on my phone and I enjoy using them all, but none of them are as convenient to use as AcronRPN when doing longer calculations. If you haven't seen it yet you really should give it a go. If RPN has a future, this is it!

Bravo - I hadn't expected anyone to figure out those solver methods until I wrote a tutorial. Glad to see that the weekend I spent writing that layout documentation wasn't for naught.

In case you hadn't noticed, the solver methods play nice together so that you don't have to keep re-entering the equation. For instance, immediately after finding the zero of tan(x)-sqrt(x) is 0.6949, you can press deriv to learn that the slope at 0.6949 is 1.095. Acron RPN will see the zero() on the top of the stack and assume those are the parameters you want for the deriv function.

You also might want to make room for the MathWhere function - it can be really handy too. For instance

Create a function for sec(x*PI/10). Press x, PI, *, 10, /, sec

Press x again as the variable for the Where

Enter 0 as the value for the Where

Press Where. You see that the sec(x*PI/10)|x=0 is 1.

Now you can enter 1 and immediately press Where again. It computes the sec(x*PI/10)|x=1

Here's a layout that includes the "where" function. As before, remove the ".txt" suffix from the attached file before running it on your Android phone / tablet. (If the phone pops up a menu, choose "open file" and then select AcronRPN as the application to open the file with.) This layout includes a row with six buttons, but to me it looks fine! I've added borders to the buttons and I've changed the "Change sign" key label from "(-)" to a more traditional "CHS".

The XML layout system works well. At first it looks completely incomprehensible but the documentation (and Notepad++ as an editor) allow simple changes without too much difficulty. It's not what I would call straightforward but I haven't had to invest days to get some decent results.

Here's a pretty decent replica of an HP32SII. It obviously isn't programmable, and there's a few other buttons I had to change or repurpose, but it gives you a good idea of what's possible through layouts.

(08-31-2017 11:46 PM)vanLudwig Wrote: Here's a pretty decent replica of an HP32SII. It obviously isn't programmable, and there's a few other buttons I had to change or repurpose, but it gives you a good idea of what's possible through layouts.

Layouts can be loaded from the stack -> open button, or launched directly from Google Drive, Downloads, a web browser, etc. Launching from Google Drive, etc. becomes necessary if your installed layout doesn’t expose an open button.

If something goes wrong, you can always get back to the stock layout by using “Clear Data” from Settings -> Apps -> Acron RPN Calculator -> Storage.

Here's the last layout I have laying around (though I'll probably make more in the future). It pretty much looks like the stock layout, but there's an extra page of buttons in the x! toolbar, and A LOT of toolbar buttons can be long-pressed for second functions. Look for the shaded upper-right corner of toolbar buttons to indicate they can be long-pressed. Almost all of the fixed buttons can be long-pressed too, so I decided not to shade those. I realize this is a bit overwhelming to use - I mainly designed it just so that I could test all the built in functionality.

factor -> Return the x-th prime number
mod -> PI(x) i.e. the number of primes less than or equal to x
gcd -> Euler Phi function

I kinda glossed over the TVM financial toolbar in my last post, but I think it deserves a closer look. If you read though the reference documentation, you might have noticed that Acron RPN doesn't have any finical functions. So, how does this work?

There's an article in the October 1977 edition of Hewlett-Packard Journal on the math behind their financial calculators. Basically, they have an equation of five variables (n, I, PV, FV, and PMT). You fill in four values and solve for the fifth such that the whole expression equals zero.

Conveniently, Acron RPN already has MathZero for doing exactly that. If you look in the behavior section of ultimate.acronrpn, you can find that when you press the toolbar button to solve for one of those variables, it invokes a sequence of keypresses that create the generic TVM function on the stack, use MathZero to solve for the variable you want, stores the result of MathZero back into that variable, then deletes the TVM equation it authored. It isn't foolproof, but it is pretty impressive what you can create in your layout xml without changing the actual sourcecode.

Here's another layout. It doesn't do anything particularly impressive but I've put the functions I use most often as long presses on number and operator keys (as you've done) and I've put labels on the keys to show this. The lower (and smaller) function label on a key is invoked by a long press.

(As with the previous layouts, remove the ".txt" extension before use.)

One slight issue - integrals appear to have a precision of around 1 part in 10^4 which is less than I'd expect, given the computing power available on a phone! Could this be tweaked in some way?

I'm pretty sure I remember my numeric algorithms professor saying that doing a trapezoidal Riemann sum wasn't worth the added cost over rectangular - you were better off spending the extra time doing additional iterations. Not sure whether I mis-remember that, or if he was just wrong, but when I sat down and really thought about it, I was able to switch my algorithm to use trapezoids with almost no cost. That improved the precision by 3-5 decimal places

That seems like a good improvement, and even with 25,000 iterations, I don't notice any slow down. I'm currently looking at releasing BETA 2 this weekend - these changes will be in it. Thanks for the great suggestion.

On a side note, how did you insert math equations in a forum post? That is really cool.

(09-06-2017 09:45 PM)vanLudwig Wrote: Then I changed from 10,000 iterations to 25,000 iterations. That improved the x^2 by two digits; it only improved the 1/x by half a digit.

Instead of thousands and tenthousands of function calls, why don't you just implement a decent integration algorithm like the Romberg method? It is iterative, i.e. you only have to do as many function calls as required for a given precision, and it does not evaluate the function at the integration limits which is another advantage.

(09-06-2017 09:45 PM)vanLudwig Wrote: On a side note, how did you insert math equations in a forum post? That is really cool.

I'm with Dieter, pick a better algorithm. For example, a two point Gaussian quadrature is exact for cubic polynomials which includes the x2 example. Romberg is an easy choice and is adaptive. Also interesting are the Gauss–Kronrod quadratures, although they will need to be made adaptive.

As for trapezoidal vs rectangular, it depends how you define the latter. Using the function value at the middle of the rectangles for the height (rather than at the left or right edge) produces an error term twice that of the trapezoidal for one less function evaluation. Using either edge to define the rectangles is worse. Wikipedia illustrates this okay. Computationally, they are about the same (but trapezoidal requires one more function evaluation).

Let's not forget that the Romberg method is based on the Trapezoidal rule. It just does a clever extrapolation based on a quite good error estimate. ;-)

FWIW, I think something like the Trapezoidal method or even the much better Simpson rule really should not get implemented in a current calculator. That's like calculating trig and log functions with just five significant digits. My first calculator back in 1977 did so, but some things have changed since then. ;-)

(09-06-2017 09:45 PM)vanLudwig Wrote: On a side note, how did you insert math equations in a forum post? That is really cool.

This thread shows how it can be done. If you want to see how the equations in each post were produced, press the "quote" button to see what the poster actually typed. It's basically \(\TeX\).

I do think that switching to an adaptive algorithm for integration would be a good idea. It's not just that it requires fewer evaluations; it allows you to be confident that the desired degree of accuracy has been reached.