1 Apr 2012 15:09

### separation of variables

Dear all,

I have written a function separable(expr,x,y) that checks if expr is separable into f(x) and g(y) and returns [f,g]. The algorithm is based on Cid (2009), webs.uvigo.es/angelcid/Archivos/Papers/IJMEST.pdf.

But the algorithm sometimes introduces an arbitrary constant, such that it returns [A*f(x),g(y)/A].
Here is an example:

(%i01) expr:exp(x*x+y*y)*(cos(x+y)+cos(x-y));
(%i02) grind(separable(expr,x,y));
[%e^x^2*cos(x),2*%e^y^2*cos(y)]\$
(%o02)                               done

(%i03) expr:y/(sin(x+3.5)+5);
(%i04) grind(separable(expr,x,y));
[4.64921677231038/(sin(x+3.5)+5),.2150899923522087*y]\$
(%o46)                               done

The first example worked fine, but the second one introduced an arbitrary constant (sin(7/2)+5=4.6492... and 1/(sin(7/2)+5)=0.2150...).
Is there a maxima way of finding the greatest common constant factor A in two expressions?
Or is it possible to find the largest subexpression that is independent of x,y?
At the moment I am thinking of using gcd(Ans[1],1/Ans[2]) and gcd(Ans[2],1/Ans[1]) and take the one that is independent on x,y as my premultiplication factor, but there may be a better way? Also, are there limitations to the input of gcd that make it fail for more general/exotic input expressions?

```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```
1 Apr 2012 16:46

### Re: separation of variables

On 4/1/12 6:09 AM, nijso beishuizen wrote:
Dear all,

I have written a function separable(expr,x,y) that checks if expr is separable into f(x) and g(y) and returns [f,g]. The algorithm is based on Cid (2009), webs.uvigo.es/angelcid/Archivos/Papers/IJMEST.pdf.

But the algorithm sometimes introduces an arbitrary constant, such that it returns [A*f(x),g(y)/A].

....

You could look at 'content',  however the gcd of floating point numbers is officially not defined.
You might have to call content more than once, as it is defined.

```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```
1 Apr 2012 20:06

### Re: Substituting a value for a differential function

```On 3/28/12, Barton Willis <willisb <at> unk.edu> wrote:

> Putative bug:
>
>    (%i1) (a : b, b : c, c : d)\$
>
> Should be b[x], not d[x], I think:
>
>    (%i2) a[x];
>    (%o2) d[x]

Not a bug, but a misfeature; the code works as intended,
but the intent is questionable.

I looked into this, and there is a loop in MEVAL1 which reevaluates
the name of the function. The code is pretty convoluted -- I'm guessing
it could be simplified a lot.

I don't know the motivation for reevaluating function names.
It would be interesting to disable that somehow to find out what,
if anything, in existing Maxima code (e.g. share) depends on it.

best

Robert Dodier
```
1 Apr 2012 21:44

### Re: Substituting a value for a differential function

Yes, please see my note from Thursday:

---------- Forwarded message ----------
From: Stavros Macrakis
Date: Thu, Mar 29, 2012 at 17:29
Subject: Re: [Maxima] infinite loop
To: Leo Butler <l_butler <at> users.sourceforge.net>
Cc: maxima <at> math.utexas.edu

This is a misfeature (i.e. it is supposed to work this way, but it is a bad idea) in the way function/array names are evaluated.  Unlike normal evaluation in Maxima, they do 'infinite evaluation'.  A simple example:

x: 'y\$
y: 'x\$
x(1) => infinite loop
x[1] => infinite loop

-s

Tested in
Maxima version: 5.26.0
Maxima build date: 13:32 1/18/2012
Host type: i686-apple-darwin11.2.0
Lisp implementation type: SBCL
Lisp implementation version: 1.0.52.0-11e4aa5

On Thu, Mar 29, 2012 at 15:16, Leo Butler  wrote:
The following leads to an infinite loop. Could someone explain why?

f(x,y) := x(1)*y(2);
f(y,x);

--
Leo Butler                <l_butler <at> users.sourceforge.net>
SDF Public Access UNIX System -   http://sdf.lonestar.org
_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

On Sun, Apr 1, 2012 at 14:06, Robert Dodier wrote:
On 3/28/12, Barton Willis <willisb <at> unk.edu> wrote:

> Putative bug:
>
>    (%i1) (a : b, b : c, c : d)\$
>
> Should be b[x], not d[x], I think:
>
>    (%i2) a[x];
>    (%o2) d[x]

Not a bug, but a misfeature; the code works as intended,
but the intent is questionable.

I looked into this, and there is a loop in MEVAL1 which reevaluates
the name of the function. The code is pretty convoluted -- I'm guessing
it could be simplified a lot.

I don't know the motivation for reevaluating function names.
It would be interesting to disable that somehow to find out what,
if anything, in existing Maxima code (e.g. share) depends on it.

best

Robert Dodier

```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```
2 Apr 2012 16:35

### x-elements of solve and the list "x"

```Hello,

I try to make a list like "x" from the solve function as the following:

for i:1 thru 3 step 1 do
( K: solve([ i*x[i]^2+y[i]=2, i*x[i]^2+z[i]=2,
x[i]+2*i*y[i]=4],[x[i],y[i],z[i]]),
display(K),
display(x[i]));

(%o27)
K=[[x[1]=1/2,y[1]=7/4,z[1]=7/4],[x[1]=0,y[1]=2,z[1]=2]]
x[1]=x[1]
K=[[x[2]=(sqrt(129)+1)/16,y[2]=-(sqrt(3)*sqrt(43)-63)/64,z[2]=-(sqrt(3)*sqrt(43)-63)/64],[x[2]=-(sqrt(129)-1)/16,y[2]=(sqrt(3)*sqrt(43)+63)/64,z[2]=(sqrt(3)*sqrt(43)+63)/64]]
x[2]=x[2]
K=[[x[3]=(sqrt(577)+1)/36,y[3]=-(sqrt(577)-143)/216,z[3]=-(sqrt(577)-143)/216],[x[3]=-(sqrt(577)-1)/36,y[3]=(sqrt(577)+143)/216,z[3]=(sqrt(577)+143)/216]]
x[3]=x[3]

What I expected is:
x[1]=1/2
x[2]=(sqrt(129)+1)/16
x[3]=sqrt(577)+1)/36
But the list "x" does not contain any x-elements of solve and I don't know why.

I would be happy for any help.

Thanks
Sara
```
2 Apr 2012 16:42

### Re: x-elements of solve and the list "x"

```On 4/2/2012 7:35 AM, Sara Pashmin wrote:
> But the list "x" does not contain any x-elements of solve and I don't know why.
>
> I would be happy for any help.
>
> Thanks
> Sara
>

I think your difficulty can be solved by

globalsolve :  true\$

By default, the unknowns are not assigned values.
```
2 Apr 2012 17:21

### expintegral_ei() bug on convergence

Dear all,

It seems that the Maxima function expintegral_ei() behaves unexpectedly for
some complex arguments. (There should be some bugs in the implementation).

Specifically, considering a line log(20.0)/2+%i*t on the complex plane and t gets
increasing, such as t=30, 40, 50.
the values can
(%i22) expintegral_ei(log(20.0)/2+30*%i);
(%o22) 3.116181583331404*%i-.1466880831183789

(%i23) expintegral_ei(log(20.0)/2+40*%i);
(%o23) 3.205076248461513*%i+.1490949857975915

(%i24) expintegral_ei(log(20.0)/2+50*%i);
(%o24) 1766.649087960532-1098.205534849491*%i

So, (%o24) indicates that somewhere betwee log(20.0)/2+40*%i and log(20.0)/2+50*%i,
there is a point where expintegral_ei() starts unstable ( not converge). This function,
however, should converge for these values. (See below for the values obtained using
mpmath in python).

>>> ei(log(20.0)/2+30j)
(-0.146702095677588 + 3.11618365490682j)
>>> ei(log(20.0)/2+40j)
(0.0823128975103259 + 3.21713799038662j)
>>> ei(log(20.0)/2+50j)
(-0.0225961649812214 + 3.05509271574427j)

Thanks and best regards,
Yasuaki Honda, Chiba, Japan

```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```
2 Apr 2012 17:52

### Re: expintegral_ei() bug on convergence

2012/4/2 本田康晃
Dear all,

It seems that the Maxima function expintegral_ei() behaves unexpectedly for
some complex arguments. (There should be some bugs in the implementation).

Specifically, considering a line log(20.0)/2+%i*t on the complex plane and t gets
increasing, such as t=30, 40, 50.
the values can
(%i22) expintegral_ei(log(20.0)/2+30*%i);
(%o22) 3.116181583331404*%i-.1466880831183789

(%i23) expintegral_ei(log(20.0)/2+40*%i);
(%o23) 3.205076248461513*%i+.1490949857975915

(%i24) expintegral_ei(log(20.0)/2+50*%i);
(%o24) 1766.649087960532-1098.205534849491*%i

So, (%o24) indicates that somewhere betwee log(20.0)/2+40*%i and log(20.0)/2+50*%i,
there is a point where expintegral_ei() starts unstable ( not converge). This function,
however, should converge for these values. (See below for the values obtained using
mpmath in python).

Thanks for reporting this.  It looks like it's really an issue with expintegral_e.  Maxima compute expintegral_ei(z) using expintegral_e(1,-z), and the expIntegral_e appears to have problems because it's using a series.  I think if the continued fraction is used instead, the problem goes away.

I'll look into it.

Ray

```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```
2 Apr 2012 18:25

### Re: how to make maxima-mode start imaxima

```Leo Butler <l_butler <at> users.sourceforge.net> writes:

> Tamas Papp <tkpapp <at> gmail.com> writes:
>
>> On Sat, 31 Mar 2012 14:06:01 +0000, Leo Butler wrote:
>>
>>> No worries. Try this:
>>>
>>> (defadvice maxima-send-region (before maxima-start-imaxima first)
>>>   "Ensures that imaxima is running and the correct flag is set." (setq
>>>   imaxima-use-maxima-mode-flag t) (unless (get-buffer
>>>   maxima-buffer-name)
>>>     (with-temp-buffer (imaxima))))
>>
>> It works with the following modification:
>>
>> (defadvice maxima-send-region (before maxima-start-imaxima first)
>>   "Ensures that imaxima is running and the correct flag is set."
>>   (setq imaxima-use-maxima-mode-flag t)
>>   (unless (get-buffer "*maxima*")
>>     (with-temp-buffer (imaxima))))
>>
>> The variable maxima-buffer-name is not defined in the version I am
>> using.
>
> Ahh, sorry, that is a personal customisation.
>
>>
>> Is there a way to show the (i)maxima window automatically when it
>> starts?
>
>
> (defadvice maxima-send-region (after show-maxima-buffer last)
>   "Show the *maxima* buffer after sending input."
>   (ignore-errors (set-window-buffer 1 "*maxima*")))
>
> In my configuration, this will split the window to show the *maxima*
> buffer, but the active buffer remains the source buffer.

After looking into this, I see maxima-send-region calls
maxima-display-buffer at the end, so you should not need to add this

--

--
Leo Butler                <l_butler <at> users.sourceforge.net>
SDF Public Access UNIX System -   http://sdf.lonestar.org
```
3 Apr 2012 02:14

### Re: x-elements of solve and the list "x"

? What do you mean by "the list x"?  There is no list x -- there are subscripted formal variables called x[1], x[2], etc.  And solve correctly finds 2 solutions for each equation -- so there is not one list of solutions.  Setting globalsolve:true will assign values to solved-for variables, but only for *linear* equations where the solutions are unique.

If you want to construct a list of (say) the positive solutions to your equations, you will have to do a little more programming work....

-s

On Mon, Apr 2, 2012 at 07:35, Sara Pashmin wrote:
Hello,

I try to make a list like "x" from the solve function as the following:

for i:1 thru 3 step 1 do
( K: solve([ i*x[i]^2+y[i]=2, i*x[i]^2+z[i]=2,
x[i]+2*i*y[i]=4],[x[i],y[i],z[i]]),
display(K),
display(x[i]));

(%o27)
K=[[x[1]=1/2,y[1]=7/4,z[1]=7/4],[x[1]=0,y[1]=2,z[1]=2]]
x[1]=x[1]
K=[[x[2]=(sqrt(129)+1)/16,y[2]=-(sqrt(3)*sqrt(43)-63)/64,z[2]=-(sqrt(3)*sqrt(43)-63)/64],[x[2]=-(sqrt(129)-1)/16,y[2]=(sqrt(3)*sqrt(43)+63)/64,z[2]=(sqrt(3)*sqrt(43)+63)/64]]
x[2]=x[2]
K=[[x[3]=(sqrt(577)+1)/36,y[3]=-(sqrt(577)-143)/216,z[3]=-(sqrt(577)-143)/216],[x[3]=-(sqrt(577)-1)/36,y[3]=(sqrt(577)+143)/216,z[3]=(sqrt(577)+143)/216]]
x[3]=x[3]

What I expected is:
x[1]=1/2
x[2]=(sqrt(129)+1)/16
x[3]=sqrt(577)+1)/36
But the list "x" does not contain any x-elements of solve and I don't know why.

I would be happy for any help.

Thanks
Sara
_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```

Gmane