Trace is a work-in-progress mathematical graphing app that I have been working on this year. The app allows users to plot graphs of a wide array of curves and functions with a wealth of styling and display options.
My goal with this app is to create a fully-featured graphing app that was native to iOS. Whilst there are many powerful graphing apps available, none feels truly at home in iOS, with many of the most popular apps not even adapting correctly to the available screen size on iPhones. Later down the line, I have plans to add many more original features such as support for complex (imaginary) numbers and recursively defined functions.
I built Trace from scratch using purely Swift and SwiftUI, without relying on any existing graphing software. This involved quite a number of challenges. The first of these involved converting textual descriptions of functions from the user (such as '-xsinx' or '-x(x-1)') into a structured, mathematical object. A sample of code illustrating some of this structure is shown below.
The biggest challenge of all was to actually plot the functions in an efficient but elegant manner. This involved a lot of head-scratching and the implementation of a great deal of algorithms, for example to handle asymptotes and to highlight turning points.