Thanx so much to all who replied to this thread. It makes sense now. I
can go back and explain it all to my students!
Thank you,
A. Jorge Garcia
Applied Math and CompSci
http://shadowfaxrant.blogspot.com
http://www.youtube.com/calcpage2009
-----Original Message-----
From: Micah James <micah.ja...@gmail.com>
To: sage-edu <sage-edu@googlegroups.com>
Sent: Wed, Sep 21, 2011 4:39 pm
Subject: Re: [sage-edu] Re: problem with booleans?
Yes, that should work also because in this case, the outputs are in
Integer Ring rather than Symbolic Ring.
If you define f and g as you mentioned, then
sage: parent(f(2))
Integer Ring
sage: parent(g(-1))
Integer Ring
sage: f(2)==g(-1)
True
On Wed, Sep 21, 2011 at 3:32 PM, A. Jorge Garcia <calcp...@aol.com>
wrote:
Micah <micah.ja...@gmail.com> wrote:
Jorge,
For what it's worth, it appears that f(2) and g(-1) are elements of
the symbolic ring, rather than the integer ring. As such, the
equation
sage: f(2)==g(-1)
is not interpreted as "evaluate this as a boolean expression".
Rather, it is interpreted as another symbolic expression. This does
not happen when the two sides of the equation are in the integer
ring.
sage: parent(0)
Integer Ring
sage: 0==0
True
but f(2) is 0 in the symbolic ring, thus the equation of symbolics is
interpreted as a symbolic element itself.
sage: parent(f(2))
Symbolic Ring
sage: f(2)==g(-1)
0 == 0
sage: parent(f(2)==g(-1))
Symbolic Ring
sage: SR(0)==SR(0)
0 == 0
As a workaround, I noticed that if you define your functions using
lambda, this does not happen.
sage: f = lambda x:x**2-4
sage: g = lambda x:x**2-2*x+1
sage: parent(f(2))
Integer Ring
sage: f(2)==g(-1)
True
This may not be the ideal way to present the functions to your class,
but it might be better than something of the form
sage: (f(2)-g(-1)).is_zero()
Here's hoping this was helpful!
-Micah
On Sep 21, 2:04 pm, "A. Jorge Garcia" <calcp...@aol.com> wrote:
> I had a weird problem in class today. Let's say I had the following
> code in a cell:
>
> f(x)=x**2-4
> g(x)=x**2+2*x+1
> f(2)==g(-1)
>
> What output should I get? I was expecting: True Am I crazy?
Needless
> to say I didn't!
>
> TIA,
> A. Jorge
>
Garciahttp://shadowfaxrant.blogspot.comhttp://www.youtube.com/calcpage200
9
--
You received this message
because
you are subscribed to the Google Groups "sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com.
To unsubscribe from this group, send email to
sage-edu+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sage-edu?hl=en.
I see. I could have swarn that I'd done this before....
Anyway, rather than lambda notation, what if I just define a function
like
this
def f(x):
return x**2-4
def g(x):
return x**2+2x+1
f(2)==g(-1)
Thanx,
A. Jorge Garcia
Applied Math and CompSci
http://shadowfaxrant.blogspot.com
http://www.youtube.com/calcpage2009
Sent via DROID on Verizon Wireless
--
You received this message because you are subscribed to the Google
Groups
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com.
To unsubscribe from this group, send email to
sage-edu+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sage-edu?hl=en.
--
You received this message because you are subscribed to the Google
Groups "sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com.
To unsubscribe from this group, send email to
sage-edu+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sage-edu?hl=en.
--
You received this message because you are subscribed to the Google Groups
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com.
To unsubscribe from this group, send email to
sage-edu+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sage-edu?hl=en.