App that will perform custom math function?

I’m not sure, but I don’t think I can do this with the Alfred app …

What I’d like to do is define a custom function, e.g. “change”.

“change(x, y)” would return the result of doing (y-x)/x. I do this calculation all the time.
For example change(50, 100) would return 1.

Is there an app which would allow me to type a keyboard shortcut, a window would open up like Alfred’s, I could type in “change(50, 100)”, and it would return “1”?


I think pCalc can do this for you.

Raycast + a custom script would do this for you. Have done this before.

The most convenient solution for you will depend on which automation tools are on your Mac. One tool I know you have is AppleScript. Here’s a script that will do it:

set change to display dialog "Give me two numbers separated by a single space" with title "Change" default answer "50 100" buttons {"Change", "Cancel"} default button "Change" cancel button "Cancel"
set my text item delimiters to " "
set x to text item 1 of (text returned of change)
set y to text item 2 of (text returned of change)
set c to (y - x) / x
display alert "The change from " & x & " to " & y & " is " & c

Unfortunately, I don’t know enough about running scripts from Alfred to get this bound to a keyboard shortcut (I’m more of a Keyboard Maestro guy). I’m sure someone else here can help you with that and probably clean up my script, too.

1 Like

Spotlight will do this if you don’t mind typing the formula.

BTW (50-100)/100 = -0.5

Not sure if the 1 is what you were after.

He said y-x not x-y.

I have a javascript bookmarklet that will do this. Stick it in the bookmarks bar of your favorite browser, and it’s a click away.

Here’s what you paste in the URL field of the bookmark (you can make the name/title whatever you want):


Ah. I stand corrected.

Here’s the function in an Alfred workflow. You can make a bunch of these once you know the format.

Relevant parts. You can just accept change 50,100 instead of adding support on line 3 for change(50,100) (choose no space after input) by taking a substring inside the parentheses. I like to support the parentheses because it feels right.

You should probably include a check for division by 0 :sunglasses:


I think @robertlf will figure it out when Infinity shows up on his clipboard. :wink:

1 Like

Thanks everyone! I’ll look these over and figure out which one best meets my needs.