I have defined a function g
as
g[t_] := (
res = 0;
i = 1;
While[i <= t,
res = res + i;
i = i + 1;
];
res);
The aim is to work with the function F[u]
, which should be the integral of g
in bounds $[0,u]$, something like
F[u_] := Integrate[g[y], {y, 0, u}]
However, the result I obtain for F
is not correct with such definition of g
. In fact, F
takes value 0 for any argument u
(my guess is that this happens because g[y]
is immediately evaluated as 0).
How can F
be redefined properly, without changing the definition of g
?
g[t_?NumericQ] := ...
instead, then doRemove["Global`*"]
and re-evaluate it. See here for other cases whereNumericQ
is needed. $\endgroup$g[t_] := Floor[t] (Floor[t] + 1) / 2
? $\endgroup$g
is a function defined exactly with a loop. In my research I`m dealing with some counting stochastic process, which cannot be defined otherwise than a sum of random variables upto certain moment. Since stating the whole problem would have been rigorous, I have asked this more general question in order to apply obtained results later in my work. $\endgroup$