ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 06 Jul 2015 10:50:31 -0500Evaluation failhttp://ask.sagemath.org/question/26374/evaluation-fail/hello,
when running "0^0" the result is "1", but when defining "f(x)=0^x" and evaluating "f(0)" the evaluation fails with "ValueError: power::eval(): pow(0,0) is undefined". I guess this one is easy to fix... :)
version: Sage Version 6.5, Release Date: 2015-02-17
regards,
manfredSun, 29 Mar 2015 05:35:31 -0500http://ask.sagemath.org/question/26374/evaluation-fail/Comment by calc314 for <p>hello,</p>
<p>when running "0^0" the result is "1", but when defining "f(x)=0^x" and evaluating "f(0)" the evaluation fails with "ValueError: power::eval(): pow(0,0) is undefined". I guess this one is easy to fix... :)</p>
<p>version: Sage Version 6.5, Release Date: 2015-02-17</p>
<p>regards,
manfred</p>
http://ask.sagemath.org/question/26374/evaluation-fail/?comment=26375#post-id-26375Using a python lambda function, this will work. That is, `f = lambda x: 0^x` will give a function that does what you want. So, this indicates that it is a matter of how Sage is defining its functions.Sun, 29 Mar 2015 08:15:25 -0500http://ask.sagemath.org/question/26374/evaluation-fail/?comment=26375#post-id-26375Answer by tmonteil for <p>hello,</p>
<p>when running "0^0" the result is "1", but when defining "f(x)=0^x" and evaluating "f(0)" the evaluation fails with "ValueError: power::eval(): pow(0,0) is undefined". I guess this one is easy to fix... :)</p>
<p>version: Sage Version 6.5, Release Date: 2015-02-17</p>
<p>regards,
manfred</p>
http://ask.sagemath.org/question/26374/evaluation-fail/?answer=26376#post-id-26376When you write:
sage: f(x)=0^x
You define a "symbolic function":
sage: type(f)
<type 'sage.symbolic.expression.Expression'>
sage: f.parent()
Callable function ring with argument x
This is a kind of mathematical formula (like `exp(cos(pi)) + log(x)`). This is an object you can derivate, integrate, and so on.
Instead you can define a Python function:
sage: def f(x):
....: return 0^x
sage: f(0)
1
sage: type(f)
<type 'function'>
For such easy-to-define function, you can be shorter, by typing:
sage: f = lambda x : 0^x
sage: f(0)
1
sage: type(f)
<type 'function'>
**EDIT**
According to your comment, it seems i misunderstood your question. Actually, the problem is not about evaluating the symbolic function `f` but about `SR(0)^SR(0)` being not defined. Thanks for reporting, @kcrisman opened [trac ticket 18088](http://trac.sagemath.org/ticket/18088).
Sun, 29 Mar 2015 09:14:09 -0500http://ask.sagemath.org/question/26374/evaluation-fail/?answer=26376#post-id-26376Comment by rws for <p>When you write:</p>
<pre><code>sage: f(x)=0^x
</code></pre>
<p>You define a "symbolic function":</p>
<pre><code>sage: type(f)
<type 'sage.symbolic.expression.Expression'>
sage: f.parent()
Callable function ring with argument x
</code></pre>
<p>This is a kind of mathematical formula (like <code>exp(cos(pi)) + log(x)</code>). This is an object you can derivate, integrate, and so on.</p>
<p>Instead you can define a Python function:</p>
<pre><code>sage: def f(x):
....: return 0^x
sage: f(0)
1
sage: type(f)
<type 'function'>
</code></pre>
<p>For such easy-to-define function, you can be shorter, by typing:</p>
<pre><code>sage: f = lambda x : 0^x
sage: f(0)
1
sage: type(f)
<type 'function'>
</code></pre>
<p><strong>EDIT</strong> </p>
<p>According to your comment, it seems i misunderstood your question. Actually, the problem is not about evaluating the symbolic function <code>f</code> but about <code>SR(0)^SR(0)</code> being not defined. Thanks for reporting, <a href="/users/41/kcrisman/">@kcrisman</a> opened <a href="http://trac.sagemath.org/ticket/18088">trac ticket 18088</a>.</p>
http://ask.sagemath.org/question/26374/evaluation-fail/?comment=27265#post-id-27265This is resolved in recent versions.Mon, 06 Jul 2015 10:50:31 -0500http://ask.sagemath.org/question/26374/evaluation-fail/?comment=27265#post-id-27265Answer by deadalps for <p>hello,</p>
<p>when running "0^0" the result is "1", but when defining "f(x)=0^x" and evaluating "f(0)" the evaluation fails with "ValueError: power::eval(): pow(0,0) is undefined". I guess this one is easy to fix... :)</p>
<p>version: Sage Version 6.5, Release Date: 2015-02-17</p>
<p>regards,
manfred</p>
http://ask.sagemath.org/question/26374/evaluation-fail/?answer=26383#post-id-26383 well thanks for the fast answer but i already knew this "workarround" ;)
i reported this problem as i thought that this was a (very small) bug since pow(0,0) evaluates to 1. hence, it does not make any sense at all that the exception "pow(0,0) is undefined" is thrown.Mon, 30 Mar 2015 09:08:44 -0500http://ask.sagemath.org/question/26374/evaluation-fail/?answer=26383#post-id-26383