I wrote this sample code to check the math here:
public void testUnit() {
If your original function has time as an independent variable (for example, as seconds) and a relation as an independent variable (for example, in percent), then the time derivative of this function will have time as an independent variable, but will have a “time ratio” like dependent.
Yes, the relationship is dimensionless, so it’s a bit strange, but you could imagine a graph of the percentage change in the day per day at the price of stocks, and then a graph of the percentage change in the day of the stock price day after day.
So what does this print?
-3.0 %/s
This is what we expect the rate of change to change from 50 to 20 percent in 10 seconds.
So, your device design should look like this:
Unit<?> magicUnit = NonSI.PERCENT.divide(SI.SECOND); Dimension magicDimension = Dimension.NONE.divide(Dimension.TIME); System.out.println(magicUnit + " measures " + magicDimension + " (" + magicUnit.getDimension() + ")");
Indeed, it prints %/s measures 1/[T] (1/[T]) , as we expect.
So, we have the Unit and Dimension, and we can do the Measures. How much do we measure? The docs say this:
Individual quantities are usually different physical sizes; although this is not required, it is necessary, for example, to have a torque and the Energy is of the same size, but has a different nature (vector for torque, scalar for energy).
So, while the frequency will appear to be the correct quantity, it does not actually express the semantic quantity, which we seem to be discussing.
In conclusion, your first line of code does not work, because in the included 1 / [T] model, the Freqency value is measured, not the Dimensionless value. Therefore, if you do not want to create your own quantity, use Unit. The size you are looking for is None / Time, or% / second if you want the correct scalar factors to be there. Finally, you decide whether you want to create your own quantity, but it can be useful if you use it in many places.
It would also be useful to get acquainted with the latest events in JScience , as it seems that they decided to Amount (with addition, subtract, multiply, divide, pow, etc.). It would be very easy to do all this dimensional analysis using sums. Just produce a percentage value minus a percentage amount and divide by the sum of a second, and it should make units for you.