I don't know how to do f(something arbitrary?) for a single pulse
but your discussion reminds me of old time-division analog computers from 1950's
where we generated a train of pulses with duty cycle proportional to some function of analog inputs.
We used them to multiply and divide analog DC voltages.
A pulse train has average value of area under the curve, (duty cycle) X height.
For example, a 0 to 10 volt square wave that's high half the time will have average value 5 volts.
So consider the following circuit, with following prerequisites:
Capacitor C is charged by E1 through R when S1 is up
and is discharged by -E2 through equal R when S1 is down
Frequency of switching is fast compared to time constant RC.
PWM is basically a zero comparator controlling ratio of switch S1's up and down times,
so as to maintain zero volts on capacitor C. Therefore Ecap remains very nearly zero.
(In the 1950's precise zero detectors were fairly easy but precision opamps were difficult.)
Let fraction of time S1 is UP = DC for
Duty
Cycle
and fraction of time S1 is DOWN = (1-DC)
So current into C is E1/R X DC
and current out of C is -E2/R X(1-DC) which equals E2/R X (DC-1)
It is apparent that to maintain Ecap = zero, the charge and discharge currents must be equal
so E1/R X DC = -E2/R X (1-DC)
E1 X DC = E2 X (DC-1)
E1/E2 = 1 - 1/DC
Output switch S2 will have same duty cycle
so Eout will have average value E3 X E1/E2
and a simple low pass filter at Eout will deliver a clean analog voltage equal to E3 X E1/E2.
Now we can use that analog computing element to derive products, quotients, squares and square roots as follows
Of course it's slow, two quadrants at best because E1 and E2 must have opposite polarity, and unstable at division by very near zero just like any divider.
but it's very handy for computing things like steam flow with density compensation from dp across an orifice as E1 and density (ρ of pressure) as E2, Eout tied back into E3 for square root of (dp X ρ) .
And absolutely impervious to Stuxnet.
Hope you don't mind this digression.
But that's one way you could make pulses with ratio of ontime / offtime in proportion to f(?) = √(a product) which i think was an earlier question..
All we ever used was the analog voltages. This circuit is called "Time Division Multiplier" and is capable of extreme precision, for analog stuff. A testament to the tenacity of those 1950's circuit designers.
Modern ones use 555 timers and opamps and are still running in nuke plants. One even used a TL494 PWM.
old jim
ps it's late and something feels uncomfortable about my duty cycle derivation
will correct in the morning if needed...