Re: [sage-support] Re: Finding a maximum value of a function on an interval?

2009-11-27 Thread Laurent
Marshall Hamilton ha scritto:
 Perhaps this is the kind of thing you want?

 sage: var('x')
 sage: f = -x^4 + 9*x^3 - 23*x^2 + 31*x - 15
 sage: f.find_maximum_on_interval(0,6)

   
Is it equivalent to what we get with
plot(f,(0,6)).get_minmax_data()
 ?


 you can get the documentation for that.  For symbolic answers you
 could do

 sage: solve(diff(f,x)==0,x)

 but of course that is more limited in what it can answer.
   
In particular, it does not solve correctly trigonometric equations : it 
finds only one solution and looses if a higher local maximum exists at 
another place.


Laurent

-- 
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


[sage-support] indentation in the output using notebook.

2009-11-27 Thread Yotam Avital
Hi.

I have a minor prolem:

I'm going through the sage tutorial and I got a little problem when I try to
create a simple table. I'm trying to do what is going here:

http://www.sagemath.org/doc/tutorial/tour_help.html#functions-indentation-and-counting

when I put the following commands:

for i in range (1,5):
print '%6s %6s %6s'%(i, i^2, i^3)

I get this output:

0  0  0

 1  1  1
 2  4  8
 3  9 27
 4 16 64


when I should get the following:

 0  0  0
 1  1  1
 2  4  8
 3  9 27
 4 16 64

What is wrong?

Thanks

-- 
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

Re: [sage-support] indentation in the output using notebook.

2009-11-27 Thread Minh Nguyen
Hi Yotam,

On Fri, Nov 27, 2009 at 9:10 PM, Yotam Avital yota...@gmail.com wrote:
 Hi.

 I have a minor prolem:

 I'm going through the sage tutorial and I got a little problem when I try to
 create a simple table. I'm trying to do what is going here:

 http://www.sagemath.org/doc/tutorial/tour_help.html#functions-indentation-and-counting

 when I put the following commands:

 for i in range (1,5):
 print '%6s %6s %6s'%(i, i^2, i^3)

 I get this output:

 0  0  0


  1  1  1
  2  4  8
  3  9 27
  4 16 64

 when I should get the following:



  0  0  0
  1  1  1
  2  4  8
  3  9 27
  4 16 64



 What is wrong?

 Thanks

I have CC'd this email to the sage-notebook mailing list in the hope
that someone reading that list might be able to help out.

-- 
Regards
Minh Van Nguyen

-- 
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


Re: [sage-support] indentation in the output using notebook.

2009-11-27 Thread Yotam Avital
great thanks.

On Fri, Nov 27, 2009 at 3:47 PM, Minh Nguyen nguyenmi...@gmail.com wrote:

 Hi Yotam,

 On Fri, Nov 27, 2009 at 9:10 PM, Yotam Avital yota...@gmail.com wrote:
  Hi.
 
  I have a minor prolem:
 
  I'm going through the sage tutorial and I got a little problem when I try
 to
  create a simple table. I'm trying to do what is going here:
 
 
 http://www.sagemath.org/doc/tutorial/tour_help.html#functions-indentation-and-counting
 
  when I put the following commands:
 
  for i in range (1,5):
  print '%6s %6s %6s'%(i, i^2, i^3)
 
  I get this output:
 
  0  0  0
 
 
   1  1  1
   2  4  8
   3  9 27
   4 16 64
 
  when I should get the following:
 
 
 
   0  0  0
   1  1  1
   2  4  8
   3  9 27
   4 16 64
 
 
 
  What is wrong?
 
  Thanks

 I have CC'd this email to the sage-notebook mailing list in the hope
 that someone reading that list might be able to help out.

 --
 Regards
 Minh Van Nguyen

 --
 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

-- 
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

Re: [sage-notebook] Re: [sage-support] indentation in the output using notebook.

2009-11-27 Thread Minh Nguyen
Hi Pat,

On Sat, Nov 28, 2009 at 1:36 AM, Pat LeSmithe qed...@gmail.com wrote:
 On 11/27/2009 05:47 AM, Minh Nguyen wrote:
 On Fri, Nov 27, 2009 at 9:10 PM, Yotam Avital yota...@gmail.com wrote:
 for i in range (1,5):
 print '%6s %6s %6s'%(i, i^2, i^3)

 I think *part* of the problem could be line 294 of sagenb.interfaces.expect:

s = s.strip().rstrip(self._prompt)


 Replacing this with

s = s.rstrip(self._prompt)

 appears to restore the expected spacing.  But quitting and reopening the
 worksheet puts

 1  1  1
 2  4  8
 3  9 27
 4 16 64

 in the output cell.  I think the problem here is line 910 (or so) of
 sagenb.notebook.cell:

out = '///\n' + out.strip()


 Replacing this with

out = '///\n' + out.strip('\n')

 seems to solve this problem.  It also makes the text representation of
 the worksheet more compact.

 Note: I haven't tested these changes extensively.

Thanks for this. I've CC'd your response to the sage-support mailing
list so that the querent could benefit from your response.

-- 
Regards
Minh Van Nguyen

-- 
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


[sage-support] unsubscribe

2009-11-27 Thread Barry Cherkas
unsubscribe

Barry Cherkas

-- 
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


Re: [sage-support] unsubscribe

2009-11-27 Thread Minh Nguyen
Hi Barry,

On Sat, Nov 28, 2009 at 4:51 AM, Barry Cherkas
barry.cher...@hunter.cuny.edu wrote:
 unsubscribe

 Barry Cherkas

This is to inform you that you are now unsubscribed from the
sage-support mailing list.

-- 
Regards
Minh Van Nguyen

-- 
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


[sage-support] numerical approximation in sage.

2009-11-27 Thread Yotam Avital
Hello.

In the tutorials there is an example for numerical approximation:

var('x y p q')
(x, y, p, q)
eq1 = p+q==9
eq2 = q*y+p*x==-6
eq3 = q*y^2+p*x^2==24
solns = solve([eq1,eq2,eq3,p==1],p,q,x,y, solution_dict=True)
[[s[p].n(30), s[q].n(30), s[x].n(30), s[y].n(30)] for s in solns]
[[1.000, 8.000, -4.8830369, -0.13962039],
 [1.000, 8.000, 3.5497035, -1.1937129]]


As I far as I can understand, solution_dict tells sage that I want the
output to be in dictionary form(that is, {x:1, y:8 ...})
I also know that the .n(30) tell sage I want the answer to have 30
digits accuracy. I can't understand though the logic of the last
command. Can any of you explain it to me?

Thanks.

-- 
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

Re: [sage-support] numerical approximation in sage.

2009-11-27 Thread Minh Nguyen
Hi Yotam,

On Sat, Nov 28, 2009 at 5:03 AM, Yotam Avital yota...@gmail.com wrote:

SNIP

 As I far as I can understand, solution_dict tells sage that I want the
 output to be in dictionary form(that is, {x:1, y:8 ...})

Yes, you're right.


 I also know that the .n(30) tell sage I want the answer to have 30 digits
 accuracy.

Not quite. The method .n(30) tells Sage that you want an approximation
with 30 bits of precision. The default is to use 53 bits of precision.
This method has two keywords: prec for specifying the number of bits
of precision; and digits for specifying the number of digits. For
example, consider the following Sage session:

{{{
[mv...@sage ~]$ sage
--
| Sage Version 4.2.1, Release Date: 2009-11-14   |
| Type notebook() for the GUI, and license() for information.|
--
sage: var('x, y, p, q');
sage: eq1 = p + q == 9
sage: eq2 = q*y + p*x == -6
sage: eq3 = q*y^2 + p*x^2 == 24
sage: solns = solve([eq1, eq2, eq3, p==1], p, q, x, y, solution_dict=True)
sage: sol = solns[0][p]
sage: # approximate sol with 30 bits of precision
sage: sol.n(30)
1.000
sage: sol.n(prec=30)
1.000
sage: # approximate sol with 30 digits of precision
sage: sol.n(digits=30)
1.0
}}}

You can find out more about the method .n() by issuing sol.n? at the
command line.


 I can't understand though the logic of the last command. Can any
 of you explain it to me?

You were asking for an approximation with 30 bits of precision. If you
want an approximation with 30 digits of precision, use the key word
digits of the method .n().

-- 
Regards
Minh Van Nguyen

-- 
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


[sage-support] Re: numerical approximation in sage.

2009-11-27 Thread John H Palmieri
On Nov 27, 10:03 am, Yotam Avital yota...@gmail.com wrote:
 Hello.

 In the tutorials there is an example for numerical approximation:

 var('x y p q')
 (x, y, p, q)
 eq1 = p+q==9
 eq2 = q*y+p*x==-6
 eq3 = q*y^2+p*x^2==24
 solns = solve([eq1,eq2,eq3,p==1],p,q,x,y, solution_dict=True)
 [[s[p].n(30), s[q].n(30), s[x].n(30), s[y].n(30)] for s in solns]
 [[1.000, 8.000, -4.8830369, -0.13962039],
  [1.000, 8.000, 3.5497035, -1.1937129]]

 As I far as I can understand, solution_dict tells sage that I want the
 output to be in dictionary form(that is, {x:1, y:8 ...})
 I also know that the .n(30) tell sage I want the answer to have 30
 digits accuracy. I can't understand though the logic of the last
 command. Can any of you explain it to me?

If you're asking about the command

[[s[p].n(30), s[q].n(30), s[x].n(30), s[y].n(30)] for s in solns]

then note first that solns is a list, and a construction like [blah
for s in solns] evaluates blah for each entry s in solns. If you
just print solns at this point, you should get

[{q: 8, x: -4/3*sqrt(10) - 2/3, p: 1, y: 1/6*sqrt(2)*sqrt(5) - 2/3},
 {q: 8, x: 4/3*sqrt(10) - 2/3, p: 1, y: -1/6*sqrt(2)*sqrt(5) - 2/3}]

Each entry s in solns is a dictionary with keys the variables p, q, x,
y.  For the first entry, s[p] is 1, s[q] is 8, etc.  So the command
that I think you were asking about prints s[p], s[q], s[x], and s[y],
each with 30 bits of precision, for each of the two solutions.

--
John

-- 
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


Re: [sage-support] Re: numerical approximation in sage.

2009-11-27 Thread Yotam Avital
My question is about the syntax and why does this syntax give a numerical
approximation.

To my understanding, solns is contracted from two arrays with  p,q,x,y being
the keys (because there are two solutions to the equations set). The part for
s in solns is putting in s ab array, and the part s[blah].n(30) asks sage
to give s[blah] in 30 bits precision.

Here is what I don't understand:

   - Is this syntax equivalent to:

for s in solns
s[q].n(30)
s[p].n(30)
s[x].n(30)
s[y].n(30)

   - Why does this method give a numerical solution.

Thanks.

On Fri, Nov 27, 2009 at 10:46 PM, John H Palmieri jhpalmier...@gmail.comwrote:

 On Nov 27, 10:03 am, Yotam Avital yota...@gmail.com wrote:
  Hello.
 
  In the tutorials there is an example for numerical approximation:
 
  var('x y p q')
  (x, y, p, q)
  eq1 = p+q==9
  eq2 = q*y+p*x==-6
  eq3 = q*y^2+p*x^2==24
  solns = solve([eq1,eq2,eq3,p==1],p,q,x,y, solution_dict=True)
  [[s[p].n(30), s[q].n(30), s[x].n(30), s[y].n(30)] for s in solns]
  [[1.000, 8.000, -4.8830369, -0.13962039],
   [1.000, 8.000, 3.5497035, -1.1937129]]
 
  As I far as I can understand, solution_dict tells sage that I want the
  output to be in dictionary form(that is, {x:1, y:8 ...})
  I also know that the .n(30) tell sage I want the answer to have 30
  digits accuracy. I can't understand though the logic of the last
  command. Can any of you explain it to me?

 If you're asking about the command

 [[s[p].n(30), s[q].n(30), s[x].n(30), s[y].n(30)] for s in solns]

 then note first that solns is a list, and a construction like [blah
 for s in solns] evaluates blah for each entry s in solns. If you
 just print solns at this point, you should get

 [{q: 8, x: -4/3*sqrt(10) - 2/3, p: 1, y: 1/6*sqrt(2)*sqrt(5) - 2/3},
  {q: 8, x: 4/3*sqrt(10) - 2/3, p: 1, y: -1/6*sqrt(2)*sqrt(5) - 2/3}]

 Each entry s in solns is a dictionary with keys the variables p, q, x,
 y.  For the first entry, s[p] is 1, s[q] is 8, etc.  So the command
 that I think you were asking about prints s[p], s[q], s[x], and s[y],
 each with 30 bits of precision, for each of the two solutions.

 --
 John

 --
 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


-- 
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

[sage-support] weird error after starting Sage 4.2.1 in terminal

2009-11-27 Thread Alex Ghitza

When I start sage-4.2.1, about 5 seconds after the sage: prompt
appears, I get this:

--
| Sage Version 4.2.1, Release Date: 2009-11-14   |
| Type notebook() for the GUI, and license() for information.|
--
sage: Traceback (most recent call last):
  File /home/ghitza/sage-devel/local/bin/sage-cleaner, line 108, in module
while cleanup()  0:
  File /home/ghitza/sage-devel/local/bin/sage-cleaner, line 53, in cleanup
if not e or (e and kill_spawned_jobs(spawned_processes, parent_pid)):
  File /home/ghitza/sage-devel/local/bin/sage-cleaner, line 75, in 
kill_spawned_jobs
os.killpg(int(pid), 9)
ValueError: invalid literal for int() with base 10: 'Cl\xd9\x02\x1f\x7fl'


I have not run into this in previous versions.  Has anyone else seen
this?


Best,
Alex


-- 
Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne
-- Australia -- http://www.ms.unimelb.edu.au/~aghitza/

-- 
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


Re: [sage-support] weird error after starting Sage 4.2.1 in terminal

2009-11-27 Thread William Stein
On Fri, Nov 27, 2009 at 3:40 PM, Alex Ghitza aghi...@gmail.com wrote:

 When I start sage-4.2.1, about 5 seconds after the sage: prompt
 appears, I get this:

 --
 | Sage Version 4.2.1, Release Date: 2009-11-14                       |
 | Type notebook() for the GUI, and license() for information.        |
 --
 sage: Traceback (most recent call last):
  File /home/ghitza/sage-devel/local/bin/sage-cleaner, line 108, in module
    while cleanup()  0:
  File /home/ghitza/sage-devel/local/bin/sage-cleaner, line 53, in cleanup
    if not e or (e and kill_spawned_jobs(spawned_processes, parent_pid)):
  File /home/ghitza/sage-devel/local/bin/sage-cleaner, line 75, in 
 kill_spawned_jobs
    os.killpg(int(pid), 9)
 ValueError: invalid literal for int() with base 10: 'Cl\xd9\x02\x1f\x7fl'


 I have not run into this in previous versions.  Has anyone else seen
 this?

I've never heard of this.   The above could be caused by some file
being corrupted.

Delete $HOME/.sage/temp to get rid of this problem.

William

-- 
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


Re: [sage-support] weird error after starting Sage 4.2.1 in terminal

2009-11-27 Thread Alex Ghitza
On Fri, Nov 27, 2009 at 03:53:39PM -0800, William Stein wrote:
 
 I've never heard of this.   The above could be caused by some file
 being corrupted.
 
 Delete $HOME/.sage/temp to get rid of this problem.
 

Thanks, that did it.


-- 
Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne
-- Australia -- http://www.ms.unimelb.edu.au/~aghitza/

-- 
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


[sage-support] Re: numerical approximation in sage.

2009-11-27 Thread kcrisman
Hi,

This is an unavoidable consequence of using Maxima's solve commands, I
think - with multiple equations, Maxima's solve uses things like
algsys, if I'm not mistaken, and those return real solutions if they
can't find symbolic ones.

With one equation the (new) behavior is to not do this automatically
(the to_poly_solve=True option would allow this), but I don't think
there is any way to avoid the possibility of this with more than one
equation.  The documentation should be clear on this in the newest
version of Sage - I hope!

- kcrisman

-- 
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