[sage-support] Re: Newbie question. How do you get Sage to show a plot?

2009-03-30 Thread William Stein

On Mon, Mar 30, 2009 at 8:17 PM, WLC  wrote:
>
>
> I just installed Sage and I am going through a few examples from the
> http://www.sagemath.org/doc/tutorial site. when I enter "circle((0,0),
> 1, rgbcolor=(1,1,0))" or "plot(cos, (-5,5))" there is a delay and then
> the comand prompt returns but I don't see a plot. Should it pop up in
> a new window, or where should I look?

*Precisely* what operating system are you using and precisely version
of Sage?  Are you using Sage on the command line or in the notebook?

If in the command line, the output of this command will tell you what
program is used to display plots (which are png images):

sage: sage.misc.viewer.png_viewer()
'sage-native-execute xdg-open'


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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Newbie question. How do you get Sage to show a plot?

2009-03-30 Thread Minh Nguyen

Hi,

On Tue, Mar 31, 2009 at 3:17 AM, WLC  wrote:
>
>
> I just installed Sage and I am going through a few examples from the
> http://www.sagemath.org/doc/tutorial site. when I enter "circle((0,0),
> 1, rgbcolor=(1,1,0))" or "plot(cos, (-5,5))" there is a delay and then
> the comand prompt returns but I don't see a plot. Should it pop up in
> a new window, or where should I look?

Images of plots are usually saved under the directory
$HOME/.sage/temp/. For example, on the machine sage.math, I can't view
a plot after invoking any of the plot related family of commands, but
I can still get the image of the plot at

$HOME/.sage/temp/sage.math.washington.edu/12688

where the number 12688 is an ID for my particular Sage session. Such
images are usually PNG and have the prefix "tmp_".

-- 
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Newbie question. How do you get Sage to show a plot?

2009-03-30 Thread Ajay Rawat
well, actually it should plot the graph in a new pop-up window(eog).
may be you try to plot these graph in notebook.
this may help you.

On Tue, Mar 31, 2009 at 8:47 AM, WLC  wrote:

>
>
> I just installed Sage and I am going through a few examples from the
> http://www.sagemath.org/doc/tutorial site. when I enter "circle((0,0),
> 1, rgbcolor=(1,1,0))" or "plot(cos, (-5,5))" there is a delay and then
> the comand prompt returns but I don't see a plot. Should it pop up in
> a new window, or where should I look?
>
> Thanks
> -WLC
>
> >
>


-- 
Ajay Rawat
Kalpakkam, IGCAR

-
Save Himalayas
-

--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Newbie question. How do you get Sage to show a plot?

2009-03-30 Thread WLC


I just installed Sage and I am going through a few examples from the
http://www.sagemath.org/doc/tutorial site. when I enter "circle((0,0),
1, rgbcolor=(1,1,0))" or "plot(cos, (-5,5))" there is a delay and then
the comand prompt returns but I don't see a plot. Should it pop up in
a new window, or where should I look?

Thanks
-WLC

--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: sage.math out for a break?

2009-03-30 Thread Justin C. Walker


On Mar 28, 2009, at 14:16 , mabshoff wrote:

>
>
>
> On Mar 28, 1:48 pm, "Justin C. Walker"  wrote:
>> Hi,
>>
>> I can't get to sage.math: ports 80 (http) and 22 (ssh) don't respond
>> and attempts to connect time-out.  'ping' works, FWIW.
>
> Must be a local problem, I can log in without problems. Things can be
> a little slow via http, but that might be just the volume of
> traffic  :)

Following up with the answer: it was a local problem, located  
somewhere near the pilot's chair (an over-zealous use of firewalling  
that clamped down on traffic from sage.math...)

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
---
If it weren't for carbon-14, I wouldn't date at all.
---



--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Why plot() won't plot this function?

2009-03-30 Thread Jason Grout

Chris Seberino wrote:
> In a new sage session...
> (Notice the A(t) function returns values just fine.  Why doesn't plot
> () like it?)
> 
> sage: W(t)=95*sqrt(t)*sin(t/6)^2
> 
> sage: R(t)=275*sin(t/3)^2
> 
> sage: def A(t):
> :  return 1200 + numerical_integral(W(x)-R(x),0,t)[0]
> :
> 
> sage: A(0)
> 1200.0
> 
> sage: A(18)
> 1309.788183281373
> 
> sage: plot(A(t),(t,0,18))
> ---
> TypeError Traceback (most recent call
> last)
> 
> /home/seb/ in ()
> 
> /home/seb/ in A(t)
> 
> /usr/local/sage-3.4-linux-PentiumM-ubuntu-8.04.1-i686-Linux/local/lib/
> python2.5/site-packages/sage/gsl/integration.so in
> sage.gsl.integration.numerical_integral (sage/gsl/integration.c:1953)
> ()
> 
> TypeError: a float is required


That's weird.  A workaround for now is the following:

list_plot([(t,A(t)) for t in [0,0.4,..,18]],plotjoined=True)

Jason


--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Why plot() won't plot this function?

2009-03-30 Thread Chris Seberino

In a new sage session...
(Notice the A(t) function returns values just fine.  Why doesn't plot
() like it?)

sage: W(t)=95*sqrt(t)*sin(t/6)^2

sage: R(t)=275*sin(t/3)^2

sage: def A(t):
:  return 1200 + numerical_integral(W(x)-R(x),0,t)[0]
:

sage: A(0)
1200.0

sage: A(18)
1309.788183281373

sage: plot(A(t),(t,0,18))
---
TypeError Traceback (most recent call
last)

/home/seb/ in ()

/home/seb/ in A(t)

/usr/local/sage-3.4-linux-PentiumM-ubuntu-8.04.1-i686-Linux/local/lib/
python2.5/site-packages/sage/gsl/integration.so in
sage.gsl.integration.numerical_integral (sage/gsl/integration.c:1953)
()

TypeError: a float is required


cs
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Unified polynomial API. Was: Leading monomial or leading term of univariate polynomials

2009-03-30 Thread simon . king

Hi!

On 23 Mrz., 12:57, Burcin Erocal  wrote:
> > I think it is not my call to provide such list. But next week I can go
> > through the list of methods of multi- and univariate polynomials, open
> > a ticket for their unification, and perhaps start a poll on sage-devel
> > concerning the suggested method names.
>
> Great! Thank you for working on this.
>
> I think a wiki page listing the different classes implementing
> polynomials, and a list of methods provided by each would be a good
> start.

I needed a bit more time, but now i created a wiki page for that
topic:
http://wiki.sagemath.org/PolynomialAPI

There are some oddities. E.g.:
 * Univariate polynomials have coeffs(), coefficients(), and list().
All three do the same AFAIK.
 * They do not provide leading monomials.
 * They have no reduce method. Is one supposed to use quo_rem instead?

My impression is that the list of methods for multivariate polynomials
is richer, and hence should be the guide line for a unified interface.
Of course, you are invited to make the list of common methods on the
wiki page longer.

Cheers,
 Simon

--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: new cell in worksheet

2009-03-30 Thread William Stein

On Mon, Mar 30, 2009 at 9:25 AM, davidp  wrote:
>
> I am running Sage 3.4 under Fedora 10.  I am having trouble inserting
> a cell (of any type) right before a text cell in a worksheet.
>
> I have tried the following:
>
> 1. Hovering the mouse just above the text cell.
> 2. Going to a calculation cell just above the text cell and trying
> shift-click, alt-click, control-click.
>
> My solution has been to leave an empty calculation cell between the
> text cell and the cells preceding the text cell.
>
> Thanks for any suggestions.
>
> Dave

The functionality you want isn't implemented yet.  I wish somebody
would implement it.

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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: new cell in worksheet

2009-03-30 Thread davidp

I am running Sage 3.4 under Fedora 10.  I am having trouble inserting
a cell (of any type) right before a text cell in a worksheet.

I have tried the following:

1. Hovering the mouse just above the text cell.
2. Going to a calculation cell just above the text cell and trying
shift-click, alt-click, control-click.

My solution has been to leave an empty calculation cell between the
text cell and the cells preceding the text cell.

Thanks for any suggestions.

Dave

On Mar 24, 2:41 am, Stan Schymanski  wrote:
> Hi Jason,
>
> Thanks a lot for that! Your proposal sounds good. Pity it hasn't been
> implemented yet, but perhaps the tickets you submitted will help. I'll
> contribute my thoughts when I have an account.
>
> Stan
>
> On Mar 23, 4:01 pm, Jason Grout  wrote:
>
> > Stan Schymanski wrote:
> > > Thanks for your feedback, Jason! Could you submit a ticket for this to
> > > be fixed/enhanced? Unfortunately, I can't do it myself.
>
> > We should get you a trac account, then.  You can follow the instructions
> > onhttp://trac.sagemath.org/sage_trac/
>
> > The bugs are nowhttp://trac.sagemath.org/sage_trac/ticket/5591
>
> > and
>
> > The bug is nowhttp://trac.sagemath.org/sage_trac/ticket/5592
>
> > As for the alt-enter and ctrl-enter thing, can you look at my proposal
> > in the last few messages in this 
> > thread:http://groups.google.com/group/sage-devel/browse_thread/thread/5892dd...
>
> > (specifically,http://groups.google.com/group/sage-devel/msg/e351edd7b62437b9)
>
> > That proposal deals with splitting cells.
>
> > Note that two adjacent text cells are merged whenever the sheet is saved
> > and reopened.  I don't know that alt-enter and ctrl-enter makes sense
> > right now (however, maybe the text cells shouldn't be merged, and maybe
> > alt-enter and ctrl-enter should make sense...)
>
> > Jasno
>
> > > Cheers,
> > > Stan
>
> > > Jason Grout wrote:
> > >> Stan Schymanski wrote:
>
> > >>> In this context, I'm having trouble inserting a calculationcellbefore
> > >>> a htmlcellor between two html cells in Sage 3.4. The Alt-Enter or
> > >>> Ctrl-Enter methods don't not work in html cells.
>
> > >> Both of these are because they have not been implemented.  Contributions
> > >> are definitely welcome!
>
> > >>> If I want toinserta
> > >>> calculationcellbefore an htmlcell, I can't just press Alt-Enter in
> > >>> the foregoing calculationcell, because this creates anewcalculation
> > >>>cellAFTER the htmlcell. Is there another way?
>
> > >> Hmmm...I'd consider this a bug.  The Alt-enter should make anew
> > >> calculationcellright after the old calculationcell(before the
> > >> following htmlcell).
>
> > >> Jason
>
> > >>> Cheers,
> > >>> Stan
>
> > >>> kcrisman wrote:
>
> >  Dear Kwankyu,
>
> > > If I write and evaluate in acellin aworksheetand if there are
> > > already cells below the one which I am evaluating, then the cursor
> > > moves into thecelljust below instead of creating anewcellfor next
> > > input. Is this behavior preferable? This is annoying at least to me.
>
> >  One of the designers can answer for the technical reasons for this
> >  design decision, but let me tell you it is very useful when you are
> >  running through aworksheetyou have already created, but changing a
> >  few things (e.g. some initial constant defined at the top)!
>
> >  But actually, if you click on "Help" you will see that Alt-Enter
> >  actually does what you require, while Ctrl-Enter splits thecelland
> >  evaluates both things.  I didn't know either of these until I looked
> >  just now, and will definitely use them now too.
>
> >  Enjoy!
>
> >  - 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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] opening a saved jmol file

2009-03-30 Thread davidp

In the sage notebook, how can I open (display) a file I saved in jmol
format?

Thanks,
Dave
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problems (?) with least squares

2009-03-30 Thread linuxgus



On Mar 30, 7:49 am, Jason Grout  wrote:
> linuxgus wrote:

...

> >     """
> >     a=p[0];b=p[1];phi=p[2];delta=p[3];X=p[4];Y=p[5]
> >     return numpy.array(x-a*numpy.cos(phi+delta)+X  ,  y-b*numpy.sin(phi
> > +delta)+Y)
>
> Here's a guess (I haven't checked it):
>
> make the above function return:
>
> return numpy.array(x-a*numpy.cos(phi+delta)+X  ,
> y-b*numpy.sin(phi+delta)+Y, type=float)
>
> Jason

--Hi, Jason.  Thank you for responding.

I tried your suggestion at work, where I am running Sage 3.3 (I will
probably upgrade to 3.4 today).  I get
TypeError: data type not understood

I used 'float' (in single quotes) and got the same error.  It is
certainly different than the error I got on Sage 3.4 at home.  What is
odd, if I run the same code (without the 'type=float') on sage 3.3 at
work, I still get the same "TypeError: data type not understood", so
Sage 3.3 and 3.4 behave differently in this respect (shouldn't both
versions give me the same error?).

Gus
--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: substitution problem

2009-03-30 Thread Jason Grout

V wrote:
> Hi,
> 
> I'm fairly new to sage with some background in maxima.
> 
> My workbook is shared at
> http://www.sagenb.org/home/pub/410/
> 
> the last three lines show the error I get.
> 
> Basically, I derive an equilibrium condition that I would like to use
> in the previous stage of my game (solving by backwards induction), but
> maxima fails (line -2) with simplifying after the substitution is
> made, even though the substitution is successful (line -3).
> 
> I expect to receive the line in the last "paragraph" as defined by
> D1p.
> 
> Is this a bug or did I made a mistake?
> 


In this line,

solve([q1==q1.substitute(q2=sol2[0][1].right()).simplify_full()], q1)

you are trying to solve for "q1", but q1 is not a variable, it's the 
expression:

f2^alpha*p1^(alpha - 1)*p2^(beta - alpha*beta)*q2^alpha*A^(1 - alpha)/f1

Did you mean to solve for a variable in the solve statement above?

Jason



--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] substitution problem

2009-03-30 Thread V

Hi,

I'm fairly new to sage with some background in maxima.

My workbook is shared at
http://www.sagenb.org/home/pub/410/

the last three lines show the error I get.

Basically, I derive an equilibrium condition that I would like to use
in the previous stage of my game (solving by backwards induction), but
maxima fails (line -2) with simplifying after the substitution is
made, even though the substitution is successful (line -3).

I expect to receive the line in the last "paragraph" as defined by
D1p.

Is this a bug or did I made a mistake?

Thanks for your help!
V

--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Rightbox, Rightsum

2009-03-30 Thread kcrisman

> > Interesting; I didn't know about this function.  Is there a reason it's
> > not defined for general single-variable expressions (if we give an
> > interval, of course)?
>
> I think the reason is historic, since David Joyner wrote the entire
> Piecewise package and associated functionality before the
> sage/calculus directory existed.   It used to be that the functions
> (like f1 above) had to be polynomials or Python functions...

Yes.  I have toyed with adding this to non-Piecewise functions but it
always ended up being easier to do it "just in time" for my course, so
I haven't done so.  That said, it would not be hard and would be a
very good thing to do.  Also, it wouldn't be hard to add that as an
integration method option (with lots of warnings, "For pedagogical
purposes only"), and probably should be.  I feel like it *is*
somewhere, but I can't remember where - maybe also in Piecewise?

- 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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Rightbox, Rightsum

2009-03-30 Thread William Stein

On Mon, Mar 30, 2009 at 7:47 AM, Jason Grout
 wrote:
>
> David Joyner wrote:
>> See
>> http://www.sagemath.org/doc/reference/sage/functions/piecewise.html
>> For example:
>>
>>
>> sage: f1(x) = x^2
>> sage: f = Piecewise([[(0,3),f1]])
>> sage: f.riemann_sum(6,mode="midpoint")
>> Piecewise defined function with 6 parts, [[(0, 1/2), 1/16], [(1/2, 1),
>> 9/16], [(1, 3/2), 25/16], [(3/2, 2), 49/16], [(2, 5/2), 81/16], [(5/2,
>> 3), 121/16]]
>>
>
>
> Interesting; I didn't know about this function.  Is there a reason it's
> not defined for general single-variable expressions (if we give an
> interval, of course)?
>

I think the reason is historic, since David Joyner wrote the entire
Piecewise package and associated functionality before the
sage/calculus directory existed.   It used to be that the functions
(like f1 above) had to be polynomials or Python functions...

 -- 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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Rightbox, Rightsum

2009-03-30 Thread Jason Grout

David Joyner wrote:
> See
> http://www.sagemath.org/doc/reference/sage/functions/piecewise.html
> For example:
> 
> 
> sage: f1(x) = x^2
> sage: f = Piecewise([[(0,3),f1]])
> sage: f.riemann_sum(6,mode="midpoint")
> Piecewise defined function with 6 parts, [[(0, 1/2), 1/16], [(1/2, 1),
> 9/16], [(1, 3/2), 25/16], [(3/2, 2), 49/16], [(2, 5/2), 81/16], [(5/2,
> 3), 121/16]]
> 


Interesting; I didn't know about this function.  Is there a reason it's 
not defined for general single-variable expressions (if we give an 
interval, of course)?

Thanks,

Jason


--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Rightbox, Rightsum

2009-03-30 Thread Harald Schilly



On Mar 30, 3:51 pm, "M.E._Mac"  wrote:
> I am taking a Calculus class and we are studying Reimann Sum. I am
> trying to plot a function with the boxes drawn in at the right
> endpoints, left endpoints, and middle points. ...

I didn't know about the method david joyner used, but this worksheet
might help you:
http://sagenb.org/pub/408/

if you code additional examples, you can send us the code if you like!

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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Rightbox, Rightsum

2009-03-30 Thread David Joyner

See
http://www.sagemath.org/doc/reference/sage/functions/piecewise.html
For example:


sage: f1(x) = x^2
sage: f = Piecewise([[(0,3),f1]])
sage: f.riemann_sum(6,mode="midpoint")
Piecewise defined function with 6 parts, [[(0, 1/2), 1/16], [(1/2, 1),
9/16], [(1, 3/2), 25/16], [(3/2, 2), 49/16], [(2, 5/2), 81/16], [(5/2,
3), 121/16]]



On Mon, Mar 30, 2009 at 9:51 AM, M.E._Mac  wrote:
>
> I am taking a Calculus class and we are studying Reimann Sum. I am
> trying to plot a function with the boxes drawn in at the right
> endpoints, left endpoints, and middle points. For example, f(x)=x^2,
> find the area under the curve on the interval [0,3], n=10, with a)
> right endpoints, b) left endpoints, and c) middle points. I can do it
> mathematically but I can not plot it yet. I have searched through the
> tutorial online, but can't seem to find anyway to do it. Any help is
> appreciated. 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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Rightbox, Rightsum

2009-03-30 Thread M.E._Mac

I am taking a Calculus class and we are studying Reimann Sum. I am
trying to plot a function with the boxes drawn in at the right
endpoints, left endpoints, and middle points. For example, f(x)=x^2,
find the area under the curve on the interval [0,3], n=10, with a)
right endpoints, b) left endpoints, and c) middle points. I can do it
mathematically but I can not plot it yet. I have searched through the
tutorial online, but can't seem to find anyway to do it. Any help is
appreciated. 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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problems (?) with least squares

2009-03-30 Thread Jason Grout

linuxgus wrote:
> I am trying to use least squares in sage.  I started with a simple
> example:  Take an ellipse, whose major and minor axes are x and y,
> respectively, turn in by -30 degrees, shift it, inject some noise, and
> then try to recover it via least squares.  All examples I have seen
> deal with a single variable (noisy y data vs. x).  I tried leastsq
> from scipy like this (this is an excerpt from a larger program in
> notebook; not all variables are used by this excerpt):
> 
> 
> import numpy,scipy,os,sys,pylab,matplotlib
> from scipy import pi as PI
> from scipy.optimize import leastsq
> 
> # Create the original ellipse
> phi=scipy.linspace(-PI,+PI,150)
> theta=var('theta')
> theta=PI/6.0
> x=numpy.cos(phi);y=0.5*numpy.sin(phi)
> theta
> 
> 
> # Rotate the axes by -30deg and shift them by (-0.25,-0.25); inject
> some noise
> xx=x*cos(theta)+y*sin(theta)+[normalvariate(0.25,.0075) for i in range
> (150)]
> yy=-x*sin(theta)+y*cos(theta)+[normalvariate(0.25,.0075) for i in range
> (150)]
> # The xx and yy arrays hold the x and y values of the noisy, tilted,
> and shifted ellipse.
> 
> # Try to recover the tilted and shifted ellipse from the noisy data
> x1,y1,x2,y2,l1,l2,X,Y,u,v=var('x1,y1,x2,y2,l1,l2,X,Y,u,v')
> 
> def residual(x,y,p):
> """  X & Y are offsets
> """
> a=p[0];b=p[1];phi=p[2];delta=p[3];X=p[4];Y=p[5]
> return numpy.array(x-a*numpy.cos(phi+delta)+X  ,  y-b*numpy.sin(phi
> +delta)+Y)


Here's a guess (I haven't checked it):

make the above function return:

return numpy.array(x-a*numpy.cos(phi+delta)+X  , 
y-b*numpy.sin(phi+delta)+Y, type=float)


Jason


--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---