Serving the Quantitative Finance Community

 
User avatar
kenwessen
Topic Author
Posts: 0
Joined: October 24th, 2012, 8:48 pm

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 12th, 2013, 10:13 am

(Posting with permission)Hi,I've written a reasonably sophisticated programmable scientific calculation system for the iPhone and iPad and would like to bring it to wider attention. Let me emphasise right up front that it is completely free - no ads, no upgrade to "pro" version, or any other way for me to profit financially from the software. Rather it was something that I put together for myself (I work as a quantitative analyst) and believe may be useful to others of similar interests.It is called "Gnomon" after the ancient greek for "one who knows", used in English to describe the indicator of a sundial.Basically I wrote it because I found myself using each of R, MATLAB and Mathematica, but none of them to any great depth. So I thought I'd put something together that allowed me to combine those features I used frequently across these systems, but represented in a manner I was personally comfortable with, and that I could extend as required and run on an iPad. (I wanted my iPad to feel like a "computer" rather than a consumer entertainment device.)I also have an OS X graphical interface to the system, as well as Mac and Windows command line interfaces (also all completely free).Everything is available at http://thewessens.net/gnomon/Help/gnomon.html, including links to detailed help and samples. I have made special use of Project Euler to validate the language capabilities and completeness, and test the interpreter (as presented on this page: http://thewessens.net/gnomon/ProjectEul ... tions.html)It functions as an interactive calculator and plotter, supports a concise scripting language (consistent syntax but may take a little getting used to) and has a large library of standard functions. Some features are: - Basic Calculations including native support for complex numbers, fractions, arbitrary precision integers - Programmable conditions, loops (while and foreach), variables, functions - Advanced data types: arrays, matrices, strings, dictionaries and stacksA full language description is here: http://thewessens.net/gnomon/Help/digit.html Here is the full list of standard functions (just over 200 of them at present). For more details see http://thewessens.net/gnomon/Help/stdlib.htmlBasic Maths and Trigonometric Functions: Ln, Log, Exp, Fact, BiCo, Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Tanh, Asinh, Acosh, Atanh, Floor, Ceil, Abs, Sign, Pi, E, I Special Functions: Gamma, LnGamma, GammaP, GammaQ, Beta, LnBeta, BetaI, BesselJ, BesselY, Erf, Erfc, ExpInt, Zeta, ZetaGen Conversion Functions: Base, Int, Dec, Frac, Complex, Str, Split, Combine, NaN Arithmetic: Arg, Conj, Re, Im, Chop, AGM, GCD, LCM, Factors, DivisorsArray Functions: Sort, KeySort, Rev, Unique, Diffs, Freq, ArrayCmp, Fill, FillIf, FnFill, Extract, Assign, Apply, Apply2D Combinatorial Functions: Shuffle, Sample, NextPerm, NextComb, NextSubset, NextPartDate Functions: Now, Date, Time, DateTime, DateSecsRandom Number Generators: SeedRand, UIRand, UDRand, GRand, ERand, GammaRand, PRand, GeoRand, BRand, NegBRandDescriptive Statistics: Mean, GeoMean, Median, Stdev, StdevP, MAD, Moments, MomentsP, Hist, Range, Z, Ranks, Correlation, LMFit, LogitDistributions: GDist, GCDF, GCDF2, GCDFInv, EDist, ECDF, ECDFInv, GammaDist, GammaCDF, GammaCDFInv, PDist, PCDF, PCDFInv, GeoDist, GeoCDF, GeoCDFInv, BDist, BCDF, BCDFInvP, BCDFInvK, NegBDist, NegBCDF, NegBCDFInvP, NegBCDFInvK, TDist, FDist, Chi2Statistical Tests: ZTest, T1Test, T2Test, Chi2Test, FTest, ANOVA, MWTest, JBTest, KSTest, Signal Analysis: FFT, IFFT, Spectrum, Peaks, LinCorr, CycCorr, LinConv, CycConv, Fisher Polynomial: Poly, PEvaL, Roots, PAdd, PSub, PMul, PDiv File I/O: FOpen, FOpenCSV, FRead, FReadFlds, FWrite, FClose Vectors and Matrices: Mat, Part, Flatten, Id, Inv, Trans, Det, MSolve, Row, Col, Diag, Trace, LU, RRE, Rank, Dim, Inner, Cross, Outer, RowEx, ColEx, RowOp, ColOp, CharP, EigenvaluesNumerical Methods: Integrate, Solve, NewtonGraphics: LinePlot, LinePlot2, LinePlot3, PlotDefs, LineDefs, SurfaceDefs, Histogram, SurfacePlot, ContourPlot, FSurfacePlot, FContourPlotI have found the system quite useful, and am posting in the simple hope it will also be of use to others.Thanks,Ken
 
User avatar
Cuchulainn
Posts: 22929
Joined: July 16th, 2004, 7:38 am

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 12th, 2013, 10:50 am

Is this like a HP calculator, but next generation?It feels very innovative.For example, could you build a Monte Carlo simulator on top of it? Best of luck with the project.
Last edited by Cuchulainn on February 11th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
kenwessen
Topic Author
Posts: 0
Joined: October 24th, 2012, 8:48 pm

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 12th, 2013, 11:53 am

Inbuilt functions all start with capitals, user defined with lowercase. This carries over to the three pre-defined constants Pi, E and I. So you need to enter E^3, Pi etcIt may not be obvious, but you can slide the entry screen across to get other views - including a free form notebook pre-filled with examples, plus detailed help. See the iOS interface description link on the web pages.I am open to contributions, but am not yet decided on making it open source. Adding functions is actually pretty easy.KenQuoteOriginally posted by: outrunAmazing! I've downloaded the iPhone version.I've a couple of off-topic first impression remarks (about the non substantial features)5*10works fine but the following is unrecognized (intuition)e^3 epipi()PIand even more non-important (something I did notice), the background image doesn't tile.Are you going to allow developers to contribute?
 
User avatar
terrorbyte
Posts: 3
Joined: July 14th, 2002, 3:00 am

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 12th, 2013, 11:59 am

kenwessen,Are you planning an Android version?
 
User avatar
kenwessen
Topic Author
Posts: 0
Joined: October 24th, 2012, 8:48 pm

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 12th, 2013, 12:05 pm

QuoteOriginally posted by: terrorbytekenwessen,Are you planning an Android version?No current plans, but the interpreter code is completely separate from the interface (as needed to manage the distinct iOS, OS X and command line versions) so putting at least a rudimentary Android interface on it would not be particularly difficult. At the moment I just don't have the time,
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 12th, 2013, 2:43 pm

Nice job! I love the extensive function list. Here's a few suggestions for version++ of the iOS app: 1) necessary fix: the cursor in the formula bar is almost invisible (dark blue line on a dark green background). It needs to be much brighter (e.g., white, yellow, orange, etc.).2) nice future feature: some way to select and copy only the formula (or parts of a formula) in a cell (not just "Copy Cell" which copies both the "input" and "output" rows of the cell). EDIT: double-tapping does put a copy of the cell's formula into the input space although it replaces whatever was in the input space rather than behaving like a copy/paste that would insert a copy at the cursor's point.3) nice future feature: cell numbering (a la Mathematica) so one can reference the output of cell N.4) minor issue: the app doesn't handle a bluetooth keyboard that well if the keyboard is turned on AFTER bringing the app is running. When the bluetooth keyboard is first activated, the onscreen one drops down but it leaves a blank lower half of the screen with the app's supplementary 2 keyboard rows at the bottom. Swiping to another screen of Gnomon and back clears this.
Last edited by Traden4Alpha on February 11th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
kenwessen
Topic Author
Posts: 0
Joined: October 24th, 2012, 8:48 pm

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 13th, 2013, 4:57 am

QuoteOriginally posted by: outrunI get this error I can't get rid of when executing s2 5. Any ideas?It doesn't know how to evaluate a blank expression. Drop the semicolon (it's a separator rather than a terminator) and define your function as:s2 () s ~ {]s*s}I'll look over all the other comments later this evening - thanks for the interest!Ken
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 13th, 2013, 11:40 am

I found an interesting little bug:f () x:xs @1 ~ {x @1 f xs @1}{x}f [1:3] +6f [1:3] ^1f [1:4] ^Evaluation failed: multiprecision overflow because of 'x'2^2// Causes "Internal Error Recommend restart of interpreter"// all subsequent formulas with the power function results in an internal error until the app is restarted.
 
User avatar
kenwessen
Topic Author
Posts: 0
Joined: October 24th, 2012, 8:48 pm

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 13th, 2013, 5:22 pm

Thanks very much for the various comments and observations. Updating the app store version takes a little over a week because of the review process, so I will see what further things are noticed over the next few days and then get a new version submitted.The overflow bug with ^ that consequently causes an internal error is not related to the recursive function. I can reproduce just by overflowing as follows:# /pImplicit printing on# 2^3^4^5Evaluation failed: multiprecision overflow because of '2^3^4^5'# 2+2Internal error (11) - restarting the interpreter is advised.# /qShould be an straightforward fix since the overflow is recognised and handled. The problem is in the subsequent cleanup of temporary memory.There doesn't seem to be a way to change the cursor colour using a public Apple API though it is a trivial change using a private one. This kind of thing can be very annoying when developing on iOS. It's ok when it's a genuine internal and you really shouldn't be playing around with it, but when it's just something they didn't bother exposing? It's a good point and I'll look into it and work out a way to improve the situation. Regarding selecting just part of a formula, the freeform input view can help meet that need, though I appreciate changing views is not always convenient. Generally for anything more than simple interactive calculation I work primarily with the free form view, then select and submit for execution.Cell number is something I am considering as well, being quite fond of the feature in Mathematica, but I think it is more than one version away.There was a question about implementation. The engine is written in C99. The vast majority of the internals are just my own vanilla code (the parser, memory management, many of the functions) with Knuth's classic "Art of Computer Programming" being an invaluable reference. I made use of the Cephes and CCMath libraries for many of the special function evaluation routines, and PLPlot for the graphics (I will put the Quartz driver code I wrote to manage this onto the website too).Ken
Last edited by kenwessen on February 12th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Gnomon - a completely free scientific calculation and graphics app for iPhone/iPad

February 13th, 2013, 7:19 pm

Thanks for your quick reply and ongoing updates. Your app is really cool!