Subject: pw.mac and assume_pos behavior/was assume_pos bug
From: Richard Hennessy
Date: Sat, 25 Oct 2008 03:51:11 -0400
Hi,
For piecewise functions I don't know if I should try to workaround assume_pos or just say don't use it. The only time I wanted to use it was when I was trying to use the fourie package and my piecewise function package at the same time. I received a lot a questions about the sign of the answer and the questions were not even worthwhile to ask so I thought they should be possible to suppress. That is when I tried to eliminate the questions by issuing assume_pos:true. That led to other problems and I eventually noticed the cause. I could rewrite fourie.mac to fix it but that may not be the fastest way to get both packages working well together which is a goal of mine. I will start hunting around the code lurking in fourie.mac, but first I have to get my peicewise function to work for non numbers so you can say it can do symbolic integration and differentiation of a piecewise function. As of this writing you cannot say that
pw([-a,1/(x-b),b,-1/(x-b), c],x) will not produce an integral.
I get
(%i1) declare([a,b,c],constant);
(%o1) done
(%i2) pw([-a,1/(x-b),b,-1/(x-b), c],x);
(%o2) (unit_step(x+a)-unit_step(x-b))/(x-b)-(unit_step(x-b)-unit_step(x-c))/(x-b)
(%i3) integrate(%, x);
(%o3) integrate((unit_step(x+a)-unit_step(x-b))/(x-b),x)-integrate((unit_step(x-b)-unit_step(x-c))/(x-b),x)
You just get the noun form which can be improved I am pretty sure.
Rich
----- Original Message -----
From: Richard Hennessy
To: Stavros Macrakis
Cc: Maxima List
Sent: Saturday, October 25, 2008 3:19 AM
Subject: Re: [Maxima] pw.mac and assume_pos behavior/was assume_pos bug
Well, I used to like assume_pos, but I never loved it. Now I like is even less. I don't recommend using assume_pos with my pw.mac package if there is a range specification that ends or starts at zero, it will cause you headaches there.
For example
(%i1) load(pw);
Defining functions pw(L,x) and pwhelp().
'nn+xx partitions `sum
'nn+xx partitions `sum
'nn+xx partitions `sum
'nn+xx partitions `sum
'nn+xx partitions `sum
'nn+xx partitions `sum
(%o1) C:/Maxima-5.16.3/share/maxima/5.16.3/share/contrib/pw.mac
(%i2) a:0;
(%o2) 0
(%i3) assume_pos:true;
(%o3) true
(%i4) plot2d([pw([-inf,-1/(x-a), a, 1/(x-a), inf],x)], [x,-1,1], [plot_format, gnuplot])$ This will not plot right
(%i5) assume_pos:false;
(%o5) false
(%i6) plot2d([pw([-inf,-1/(x-a), a, 1/(x-a), inf],x)], [x,-1,1], [plot_format, gnuplot])$ This is okay
If a is nonzero then both plots are okay. Very strange. I may try to find a workaround to using assume_pos, since it is useful sometimes but not if you get wrong results.
Rich
----- Original Message -----
From: Stavros Macrakis
To: Richard Hennessy
Cc: Maxima List
Sent: Friday, October 24, 2008 10:15 PM
Subject: Re: [Maxima] assume_pos bug
On Fri, Oct 24, 2008 at 9:56 PM, Richard Hennessy <rvh2007 at comcast.net> wrote:
...It seems to me that assume_pos is a patch to "fix" a much deeper problem with Maxima's asksign. It is not a very good
one.
I absolutely agree that assume_pos is a terrible hack and very likely to cause problems. It would probably be a good idea to include some sort of warning in the documentation making that explicit.
You can get into trouble even if you read the documentation.
? The documentation seems pretty clear: assume_pos tells Maxima to assume that all unknown variables are positive. If this is a safe assumption, fine. If not, you will get into trouble. A simpler example along the same lines:
assume_pos: true$
ex: abs(x) => x
ex, x=-5 => -5
Oh, horrors! abs(x) can never be -5! But assume_pos:true asserts that x cannot be negative. Maxima relied on the assertion. Is that Maxima's fault or the user's?
-s
--------------------------------------------------------------------------------
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima