Thank you, that explains the behavior.
- Mihai

On Saturday, April 18, 2020 at 6:00:50 PM UTC+10, Markus Wageringel wrote:
>
> Am Donnerstag, 16. April 2020 13:39:39 UTC+2 schrieb Mihai:
>>
>> fn = diff(FN(x,n), x)
>> mean(n) = integral(fn(x, n), (x, 0, oo))
>>
>  
> The main problem with this is that `fn` is just an expression, not a 
> function of `(x, n)`. The call `fn(x, n)` switches the position of x and n, 
> as apparently the arguments of the expression are listed in alphabetical 
> order.
>
> sage: fn
> n*(1/(e^(-x) + 1))^(n - 1)*e^(-x)/(e^(-x) + 1)^2
> sage: fn.arguments()
> (n, x)
> sage: fn(x, n)
> x*(e^(-n) + 1)^(-x + 1)*e^(-n)/(e^(-n) + 1)^2
>
> With that in mind, replacing `fn(x, n)` by just `fn` in the integral leads 
> to the output that Michael obtained, so apparently Sage (or Maxima) has 
> difficulties to compute this integral symbolically for all n. However, if 
> you replace n by an actual integer before integrating, you get better 
> results:
>
> sage: F(x)=1/(1 + exp(-x))
> sage: FN(x,n) = F(x)**n
> sage: fn = diff(FN(x,n), x)
> sage: mean = lambda k: integral(fn.subs({n: k}), (x, 0, oo))
> sage: [mean(k) for k in (1..10)]
> [1/2, 3/4, 7/8, 15/16, 31/32, 63/64, 127/128, 255/256, 511/512, 1023/1024]
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/68ef06ea-bad4-4ef2-bc84-c0ae2b66937f%40googlegroups.com.

Reply via email to