[sage-support] Mathematically naive (and incorrect) output

2014-07-21 Thread Jesús Torrado
Hi guys,

This is so simple that probably someone else has already noticed it, but 
just in case:

sage: x,t = var('x,t')
sage: f = (1-x)/(1-x*cos(t))
sage: f(x=1)
0
sage: f(t=0)(x=1)
1

The second one is, of course, the correct answer. (FYI, Mathematica9 fails, 
too.)

Wouldn't the first one return some sort of conditional expression: if t=0 
then 1, else 0

I would be happy to help in the debugging, if I can get some indication of 
what is running in the background, i.e. what function is called when one 
does the substitution f(x=1).

Cheers,
Jesús Torrado

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Mathematically naive (and incorrect) output

2014-07-21 Thread kcrisman


 Hi guys,

 This is so simple that probably someone else has already noticed it, but 
 just in case:

 sage: x,t = var('x,t')
 sage: f = (1-x)/(1-x*cos(t))
 sage: f(x=1)
 0
 sage: f(t=0)(x=1)
 1


My guess is that this is more of a convention than anything else.

sage: x/x
1
sage: 0/x
0

Maxima:
(%i1) x/x;
(%o1)  1
(%i2) 0/x;
(%o2)  0

If Mma and Maple do it too, that would be my guess.  In any case, it is 
'known' and I bet you'll find other examples with a search of the email 
lists (though searching for x/x might be hard!).  It's possible to not 
immediately do such reductions

sage: x.mul(1/x,hold=True)
x/x

but I'm not sure how to combine that with the substitution that you are 
doing.

- kcrisman

The second one is, of course, the correct answer. (FYI, Mathematica9 fails, 
 too.)

 Wouldn't the first one return some sort of conditional expression: if t=0 
 then 1, else 0

 I would be happy to help in the debugging, if I can get some indication of 
 what is running in the background, i.e. what function is called when one 
 does the substitution f(x=1).

 Cheers,
 Jesús Torrado


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] Re: Mathematically naive (and incorrect) output

2014-07-21 Thread Jesús TC
Thanks for the answer, kcrisman!

 My guess is that this is more of a convention than anything else.
 [...]
 sage: 0/x
 0
 If Mma and Maple do it too, that would be my guess.  In any case, it is
 'known' and I bet you'll find other examples with a search of the email
 lists (though searching for x/x might be hard!).

Mathematica does indeed the same for 0/x. It may be a convention, so
I guess there is no room to freak out because it's just wrong!.

But it makes me sad, since I will not be able to avoid a feeling of
insecurity when substituting variables that I didn't have before :(

Isn't there a way to answer with an undetermined in those cases?

Best,
Jesús

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] Re: Mathematically naive (and incorrect) output

2014-07-21 Thread John Cremona
The expression y = (1-x)/(1-x*cos(t)) is, as given, undefined whenever
x*cos(t)=1, for example at (x,t)=(1,0).

When x=1 it simplifies to 0/(1-cos(t)), which equals 0 except where
cos(t)=1 where it is undefined but has a limiting value of 0.

When t=0 it simplfies to (1-x)/(1-x), which equals 1 except when x=1
where it is undefined, but has a limiting value of 1.

So you get different limits when first x - 1 and then t-0 compared
with first t-0 and then x-1.  The function has no continuous
extension to (x,t)=(1,0).  Hence I would not expect a computer algebra
system to give the same answers with simple substitutions in the two
orders.

On 21 July 2014 15:14, kcrisman kcris...@gmail.com wrote:
 Hi guys,

 This is so simple that probably someone else has already noticed it, but
 just in case:

 sage: x,t = var('x,t')
 sage: f = (1-x)/(1-x*cos(t))
 sage: f(x=1)
 0
 sage: f(t=0)(x=1)
 1


 My guess is that this is more of a convention than anything else.

 sage: x/x
 1
 sage: 0/x
 0

 Maxima:
 (%i1) x/x;
 (%o1)  1
 (%i2) 0/x;
 (%o2)  0

 If Mma and Maple do it too, that would be my guess.  In any case, it is
 'known' and I bet you'll find other examples with a search of the email
 lists (though searching for x/x might be hard!).  It's possible to not
 immediately do such reductions

 sage: x.mul(1/x,hold=True)
 x/x

 but I'm not sure how to combine that with the substitution that you are
 doing.

 - kcrisman

 The second one is, of course, the correct answer. (FYI, Mathematica9
 fails, too.)

 Wouldn't the first one return some sort of conditional expression: if t=0
 then 1, else 0

 I would be happy to help in the debugging, if I can get some indication of
 what is running in the background, i.e. what function is called when one
 does the substitution f(x=1).

 Cheers,
 Jesús Torrado

 --
 You received this message because you are subscribed to the Google Groups
 sage-support group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to sage-support+unsubscr...@googlegroups.com.
 To post to this group, send email to sage-support@googlegroups.com.
 Visit this group at http://groups.google.com/group/sage-support.
 For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Got sagenb running, need help

2014-07-21 Thread Jole Bradbury
Could you push me in the right direction? Would Django be a good tool to 
accomplish this with?

On Tuesday, July 15, 2014 3:32:53 PM UTC-4, Nils Bruin wrote:

 On Tuesday, July 15, 2014 11:28:35 AM UTC-7, Jole Bradbury wrote:

 I can't. I've tried compiling sagecell using the instructions posted 
 online and have gotten countless errors. It appears that it is because I am 
 running 10.9 not 10.6, but I cannot revert back to 10.6.


 OSX 10.9 I presume? Just make a virtual machine with your favourite Linux 
 flavour and set it up there. If this server is going to be facing  anything 
 remotely public, it will need insane lockdown anyway and running on a 
 virtual machine tends to be the first step for that anyway nowadays. That 
 frees you from 10.9 worries already.

 The problem with communicating with the regular notebook via curl is that 
 there is quite a bit of state (including authentication!) on the browser 
 side. You'd have to track that and ensure that curl has that available. 
 You'd end up implementing the network facing part of a browser. I imagine 
 that some python libraries would be more suitable for that.


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Got sagenb running, need help

2014-07-21 Thread Nils Bruin
On Monday, July 21, 2014 8:56:14 AM UTC-7, Jole Bradbury wrote:

 Could you push me in the right direction? Would Django be a good tool to 
 accomplish this with?


Your top-post makes it a little difficult to determine what with is. Do 
you mean communicating with a notebook server? In that case, the answer 
is probably no. I have no experience with django myself, but I have seen it 
mentioned in the context of building servers, not clients. If you need to 
programmatically communicate with a webserver, probably something like the 
python library urllib or urllib2 is the most convenient route to go. 
I'm sure other modern languages would have similar libraries available.
 
If you just need to be able to let sage compute little, self-contained code 
snippets, rather than manage whole interactive computation sessions and 
worksheets, it's probably easier to communicate with a sagecell server 
rather than a notebook server. You could start testing the client-side by 
using an already-set up cell server and if that works for you, you could 
try to figure out how to set up your own cell server.

If neither the notebook nor the cellserver provide you with a convenient 
server-side model, you could try to build your own server, in which case 
installing django in sage may be something you might try, although keeping 
separation between the server process and the sage worker process is 
probably a good idea (both sagecell and sagenb do that). If you're going to 
build your own server, looking at cellserver is probably a good idea.

If you do not know these things already, you probably haven't developed a 
web application before (I haven't myself either). There is a good chance 
that you wouldn't know all the security pitfalls that you would need to 
navigate (I certainly wouldn't trust myself for it), so you should 
absolutely try to find someone to help you with the security side of 
things. It's probably not practical to expect your service will be without 
security flaws, but at least you don't want it to be the easiest target out 
there (restricting access to it helps for that already).

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Got sagenb running, need help

2014-07-21 Thread LBerlioz
I agree that using the notebook is probably a bad idea. Have you tried 
using sage's -c flag? according to the command line help -c cmd   --
Evaluates cmd as sage code. In addition if you are using python you could 
use the subprocess module. I'm thinking something like:

check_output(['/SAGEPATH/sage', '-c ' + 'your command'])

haven't tried it myself though..

On Saturday, July 12, 2014 5:10:09 PM UTC-4, Jole Bradbury wrote:

 Ran 

 sage: import sagenb.notebook.notebook_object as nb

 sage: nb.notebook(directory=mynotebook)

 And got the server running, I can log in on localhost.



 My problem is that for the past few weeks all I've been trying to do is 
 set up a server *where data can be sent and evaluated and sent back,* my 
 users will be sending requests from a separate site. I have been trying curl 
 --data x http://localhost:8080/home/admin/0/


 But keep getting !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2 Final//EN

 title405 Method Not Allowed/title

 h1Method Not Allowed/h1

 pThe method is not allowed for the requested URL./p




 I really need to just send an http request and get it evaluated and get an 
 httpresponse. Can someone please help with that?


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.