score:0

if you're looking for exponential decay, do you need to use math.pow()? what's wrong with something like

left = left*factor

where 0 < factor < 1?

looking at some documentation for math.pow(), the two arguments are base and exponent. in your example, left - 30^30 doesn't make much sense because it will result in a vastly negative number and then default to 0.

an expression using math.pow() that will give the ith term of an exponential decay sequence is

start_value * math.pow(factor, i)

where again, 0 < factor < 1. the reduction in the value that you start with is compounded exponentially over each iteration.

score:2

according to the graph, what you want is to start at (0,10) and then divide y by 2 every time x is incremented by 1.

try this:

var time_data = [];
var value_data = [];

for (let i=0;i<=10;++i) {
    time_data.push(i);
    value_data.push(10/math.pow(2,i));
}

this can be mathematically written as a decreasing exponential: 10 * 2^(-x) or if you prefer 10 * exp(-ln(2) * x)


Related Query

More Query from same tag