# Notation to represent frequency and acceleration in preparation for algorithms

I hope this is the right place to ask. IMO it's the most appropriate SE site. I would have chosen mathematics; I didnt because I am using units such as force and Hz, and want equations to have equivalent units on both sides.

My task: programming microcontroller algorithms that calculate between time periods, frequencies and acceleration, for control of an electric motor.

The problem: I am having trouble establishing algebraic terms that are conceptually consistent, and equations with them that result in consistent units, such as Hz, seconds, etc.

A walkthrough of one example:

I want to accelerate a motor from standstill, at a constant rate. Let $t_0$ be this time, in seconds, where $t=0$.

Every $t_A$ seconds, the microcontroller will increase the frequency of rotations by $f_A$ Hz.

Let $n$ be the number of frequency increments. Therefore, $t_n=n×t_A$.

Let $f_n$ be the frequency in Hz of rotations at time $t_n$ seconds.

Therefore: $f_{n+1}=f_n+f_A$, both sides in Hz.

The problem comes when I try to find notation for time periods and acceleration: I need notation and equations to convert between frequency and time periods, and define acceleration with appropriate units.

The time period of revolutions at $t=t_n$: should it be called $t_{f_n}$?

The change in time period per revolution at $t_n$: should this be called $t_{a_{f_n}}$?

The depth of subscripts is getting ridiculous. And I'm not even sure if it is logical or a mathematically sound approach.

I'm not sure if the following works. It gives the change in time period per revolution at $t_n$, ($t_{a_{f_n}}$), given the time period of changes of frequency of rotation ($t_A$), the rate of rotation at $t_n$ ($f_n$) and $t_{n+1}$ ($f_{n+1}$):

$t_{a_{f_n}} = (1/ f_n ) - (1/ f_{n+1})$

Surely $t_{a_{f_n}}$ should have no units, since it is seconds per second, effectively? And the right hand side is in seconds?

Similarly, a glaring inconsistency is that units of $f_A$ are Hz/s or $s^{-2}$, yet $f_n$ is in Hz.

I'm thoroughly lost! P.S. this probably sounds like homework; it's just a personal project that I want to do the right way, as it will probably get more complex and I'm sure good algebra will help. Thanks!

• My personal preference (!) would be $f_n$ for equidistant sampling with a sampling frequency $f_s$ and sampling period $T_s$ and $f_{t_n}$ for non-equidistant sampling at arbitrary sampling times $t_n$. If you don't like subscripts, you can always write $f(n)$ and $t(n)$ and $f(t(n))$ or mixed notation (probably the cleanest) $f(t_n)$. As for the units, what you are really doing is $f_{n+1}=f_n + T_s\alpha_n$, where $\alpha_n$ is an angular acceleration term that has units of [$1/s^2$], however, if $T_s$ is constant, you can save yourself the multiplication and use $T_s\alpha_n=\Delta f_n$. – CuriousOne Jul 1 '16 at 20:00
• @Jodes , try to select the answer that is the easiest to interpret one or two years from now, after you haven't seen the algorithms or code for some time. And, based on my own experience from the past, where I couldn't interpret my own code after some time had elapsed, it would be helpful to document your solution in something like a Word document, so you can quickly refresh your memory at a future date. – David White Jul 2 '16 at 0:01
• the Signal Processing SE is a good place for questions like this. – robert bristow-johnson Jul 2 '16 at 3:49
• I chose WolphramJonny's answer because it was most concise and addressed core isues. Previous's answer was mainly useful because it also highlighted what standard notation would be, and more. Docscience's answer was mainly useful because it also gave an approach for documentation within the code itself, and pointing out that consistency is the most important respect rather than choice of notation, and more. – CL22 Jul 2 '16 at 11:35

I would name the period at $n$ as $P_n$, and to the change in period as $\Delta P_n$. In such a case you have the rate of change of the period, that is the change in period per unit of time is $\Delta P/t_A=\left(\frac{1}{f_{n+1}}-\frac{1}{f_n}\right)/t_A$.

However, to define the angular acceleration, $\alpha$, you do not need the period, the definition is $\alpha=\frac{\Delta f}{\Delta t}=f_A/t_A$, which is constant in this case.

You typically cannot write subscripts or superscripts (easily) as comments in code, so I'll assume you are rather interested in writing this into a specification or some kind of documentation that does support such notation. When notation becomes cumbersome, here's what I'll generally do:

1) for discrete increment always use $(n), or (k)$ or the like following the variable such as $t(k-1), r(n)$, etc.

2) For derivatives of variables use overscript notation like $\dot{p}$ for example.

3) For primary definition of a variable such as the time at which a signal is high use subscripts such as $x_{hi} (n)$ for example

5) And if you still run out of places, and as a final resort you can start compounding variable names like acceler_rotor for example

Up to 4) gives you a fairly compact notation. Most people though don't bother since the purpose is not to write a mathematical description, but rather code, so they just use the method in 5).

It's really up to you. No one is going to call you out or say you've done it wrong.

Consistent notation is what matters. Being inconsistent is wrong.

I would choose as notation conventions: $\Delta X$ for a constant increment, ie if $X_{n}-X_{n-1}=\Delta X$ for all n
and with underscript otherwise: $\Delta X_n=X_{n}-X_{n-1}$
I prefer the increment to have the index of the value it produces (adding increment $\Delta X_n$ gives value $X_{n}$) but that's a matter of taste.

It's not clear to me what the A underscore means, is it necessary? If not, I'd take $\Delta f$ and $\Delta t$ for the increments (your$f_A$ and $t_A$)

$f_n$ and $t_n$ for the values; $f_n=f_{n-1}+\Delta f$ and $t_n=t_{n-1}+\Delta t$
$T_n$ for the period (because it's the standard notation) $\Delta T_n$ for the increment,
$T_n=1/f_n$ and $\Delta T_n=T_n-T_{n-1}=1/f_n-1/f_{n-1}$ That makes $\Delta T_n$ negative, but it's consistent

Not sure about your units, $f_A$ (my $\Delta f$) isn't Hz/s, it's the increment in Hz added in each step, but a step isn't necessarily 1 second, that depends on the value of $\Delta t$. But you can choose a Hz/s value and calculate the step increase needed to achieve that, or the other way around, calculate the Hz/s value to display..

## protected by Qmechanic♦Jul 2 '16 at 3:42

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).