Re: [sage-support] Piecewise Function Fails to Evaluate in its Domain

2019-04-03 Thread David Joyner
On Wed, Apr 3, 2019 at 2:47 PM wrote: > The simplest example: > > f = piecewise([[[-pi-1, -pi/2], 0], [(-pi/2,pi/2), 1], [[pi/2, pi+1], 0]]) > print(f(-pi)) > > I'm not sure why it isn't evaluating symbolic numbers like pi, but here's a work-around: sage: f = piecewise([((-pi-*1*, -pi/*2*), *0*)

[sage-support] Piecewise Function Fails to Evaluate in its Domain

2019-04-03 Thread brandonhgomes
The simplest example: f = piecewise([[[-pi-1, -pi/2], 0], [(-pi/2,pi/2), 1], [[pi/2, pi+1], 0]]) print(f(-pi)) which gives the traceback: TypeError Traceback (most recent call last) in () > 1 f(-pi) /Applications/SageMath-8.7.app/Contents/Resources/sage/loca

Re: [sage-support] Piecewise polynomials in general

2018-01-25 Thread David Joyner
On Wed, Jan 24, 2018 at 8:13 PM, Anton Sherwood wrote: > Speaking of piecewise functions, does anyone happen to know of a piecewise > polynomial object for Python? I tried writing one (based on numpy.poly1d) > but its integration method seems to have a bug. It surprises me that I > haven't found

[sage-support] Piecewise polynomials in general

2018-01-25 Thread Anton Sherwood
Speaking of piecewise functions, does anyone happen to know of a piecewise polynomial object for Python? I tried writing one (based on numpy.poly1d) but its integration method seems to have a bug. It surprises me that I haven't found one on the fertile Web. -- *\\* Anton Sherwood *\\* www

Re: [sage-support] Piecewise plot not smooth in png

2018-01-24 Thread Volker Braun
The easiest workaround is to switch to vector-graphics output: %display graphics vector r = var('r') plot(2*r - r^2, r, 0, 1) + plot(1, r, 1, 2) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving

Re: [sage-support] Piecewise plot not smooth in png

2018-01-22 Thread Simon Willerton
On Monday, January 22, 2018 at 12:07:07 AM UTC, Simon Willerton wrote: > > > On Sunday, January 21, 2018 at 7:02:24 PM UTC, William wrote: >> >> >> On Sun, Jan 21, 2018 at 9:01 AM Simon Willerton >> wrote: >> >>> Hi! >>> >>> There seems to be a bug in the plotting in the Jupyter notebook. The

Re: [sage-support] Piecewise plot not smooth in png

2018-01-21 Thread Simon Willerton
On Sunday, January 21, 2018 at 7:02:24 PM UTC, William wrote: > > > On Sun, Jan 21, 2018 at 9:01 AM Simon Willerton > wrote: > >> Hi! >> >> There seems to be a bug in the plotting in the Jupyter notebook. The >> following piecewise defined function should be smooth at r=1 but the plot >> is no

Re: [sage-support] Piecewise plot not smooth on Jupyter

2018-01-21 Thread William Stein
On Sun, Jan 21, 2018 at 9:01 AM Simon Willerton wrote: > Hi! > > There seems to be a bug in the plotting in the Jupyter notebook. The > following piecewise defined function should be smooth at r=1 but the plot > is not; the first part of the plot seems to be lifted slightly. I noticed > this in

[sage-support] Piecewise plot not smooth on Jupyter

2018-01-21 Thread Simon Willerton
Hi! There seems to be a bug in the plotting in the Jupyter notebook. The following piecewise defined function should be smooth at r=1 but the plot is not; the first part of the plot seems to be lifted slightly. I noticed this in a more complicated example but this is a reasonably minimal case

[sage-support] [piecewise] AttributeError: ComplexField_class_with_category object has no attribute complex_field

2017-10-29 Thread Marcel Partap
For graphing strain load on a shaft in relation to coordinate x, I have created a set of piecewise functions. Now I wanted to munge them into a single parametrized vector to easily get the length via norm() at a specified point. M_Tx = piecewise([[[0, l1], M_t], [(l1, l1+l2), 0]]) M_by = piecew

[sage-support] Piecewise function

2016-02-11 Thread João Alberto Ferreira
I have a function g(x) equal to x^2 if x >= 5, and equal to 2*x if x < 5. I constructed the piecewise function as follows: g1(x) = x**2 g2(x) = 2*x g = Piecewise([[(-Infinity,5),g2],[(5,Infinity),g1]]) When I evaluate f(5), it returns 35/2 because it evaluates g1(5), g2(5) and returns the avera

Re: [sage-support] piecewise

2012-12-01 Thread Michael Orlitzky
On 12/01/2012 09:34 AM, kcrisman wrote: > > > On Friday, November 30, 2012 11:16:48 PM UTC-5, Michael Orlitzky wrote: > > On 11/30/2012 10:12 PM, Jason Grout wrote: > > > > Is there something better? I tried to get piecewise to work, but I > > couldn't plot, integrate, etc., the

Re: [sage-support] piecewise

2012-12-01 Thread kcrisman
On Friday, November 30, 2012 11:16:48 PM UTC-5, Michael Orlitzky wrote: > > On 11/30/2012 10:12 PM, Jason Grout wrote: > > > > Is there something better? I tried to get piecewise to work, but I > > couldn't plot, integrate, etc., the function. > > > > I've collected a lot of code over the y

Re: [sage-support] piecewise

2012-11-30 Thread Michael Orlitzky
On 11/30/2012 10:12 PM, Jason Grout wrote: > > Is there something better? I tried to get piecewise to work, but I > couldn't plot, integrate, etc., the function. > I've collected a lot of code over the years for working with piecewise functions, but most of it was written before I knew anythin

Re: [sage-support] piecewise

2012-11-30 Thread David Joyner
On Fri, Nov 30, 2012 at 10:12 PM, Jason Grout wrote: > A friend just asked me about piecewise functions in Sage (how to construct, > plot, differentiate, integrate, etc., them). I came up with two answers for > plotting: > > * use python functions: > > def f(t): > return t^2*(0<=t<=1) + (t-1)

[sage-support] piecewise

2012-11-30 Thread Jason Grout
A friend just asked me about piecewise functions in Sage (how to construct, plot, differentiate, integrate, etc., them). I came up with two answers for plotting: * use python functions: def f(t): return t^2*(0<=t<=1) + (t-1)*(1Is there something better? I tried to get piecewise to work,

[sage-support] Piecewise functions that are discontinuous in one point

2011-06-08 Thread Felipo Bacani
Hello. How do I define a piecewise function that are discontinuous in one point? I mean, how do I define a piecewise function f(x) if it is like xif 0 in () /opt/sage-4.6.2-linux-32bit-ubuntu_10.04_lts-i686-Linux-i686-Linux/local/lib/python2.6/site-packages/sage/functions/piecewise.pyc

[sage-support] Piecewise Function gotcha - bug or feature?

2009-10-15 Thread erikson1970
Piecewise Function: endpoint gotcha - bug or feature? It seems that the piecewise function (which requires overlapping endpoints for the specified function intervals) does some unadvertised averaging for results for values at the endpoints. See the sage output from the input below. Rather than p

[sage-support] Piecewise function definition

2009-07-21 Thread Doug
I'm trying to do something that seems very simple but isn't working. Hence the post here :) I want to define a very simple piecewise linear function. It's linear with slope alpha up to a knot at c and then it's linear with slope beta. Here's what I thought might work: f(x) = (x<=c)*alpha*x

[sage-support] piecewise defined functions and composition

2008-06-11 Thread houp
Hello. I'd like to have some simple piecewise defined function like: f = Piecewise([[[0,1],1]]) and the composite it with some other function like h = x - 1 I've tried somethine like this: f1 = lambda x:1 f2 = lambda x:x+2 f = piecewise([[[0,1],f1]]) f(f2) and it fails with: Traceback (most r