I think I've got a vague idea what happens here... The same thing also
happens when
I define the max() function myself:

sage: def my_max(x,y):
sage:     if(x>y): return x
sage:     else: return y

sage: fermi2(x,y,d,L) = 1 - 1/( exp( ( my_max(abs(x),abs(y))-L) /d)  +
1)

sage: fermi2
(x, y, d, L) |--> -1/(e^(-(L - abs(y))/d) + 1) + 1

This looks a bit like max(x,y) gets passed the the objects 'abs(x)'
and 'abs(y)'
and decides, for whatever reason, that 'abs(x)' is not greater than
'abs(y)', so
the else-clause gets executed and we are left with abs(y). Does this
make sense to
you? (I'm just thinking aloud, I got no idea how sage actually does
it)

Most likely the internal "max" function is defined in rather the same
way (it
just returns abs(x) instead of abs(y). )

The bottom line seems to be that it is a very dangerous game to mix
symbolic expressions and python functions. Is there some way to
control
when (and how) Sage evaluates expressions and invokes python
functions?
Something like saying "first evaluate abs(x) and abs(y) and then
invoke the
python function max() with the result of the evaluation"?


On Mar 12, 5:49 pm, Harald Schilly <harald.schi...@gmail.com> wrote:
> Ah, I got it, the max function is evaluated during the definition of
> the function, look:
>
> sage: fermi(x,y,d,L) = 1 - 1/( exp( ( max(abs(x),abs(y))-L) /d)  + 1)
> sage: fermi
> (x, y, d, L) |--> -1/(e^(-(L - abs(x))/d) + 1) + 1
>
> especially:
> sage: max(abs(x),abs(y))
> abs(x)
>
> There is no y any more!
>
> H

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to