Icon

Trace

iOS Graphing App

App Concept

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.

A Beautiful Graphing Experience

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.

Phone

Graphing View

Phone

Styled Curves

Phone

Custom Keyboard

Phone

Curve Style

Phone

Inline Menus

How the App Works

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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 import Foundation protocol Expression { var value: (Assignment) -> Double? { get } var debugDescription: String { get } } protocol Symbol { var validator: (String) -> Bool { get } var description: String { get } } protocol Operator { var priority: Int { get } } struct UnaryOperator: Symbol, Operator { var priority: Int var description: String var validator: (String) -> Bool var closure: (Double?) -> (Double?) } // ...

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.

Back to Home Page

© Alasdair Casperd 2024