1 Aug 03:16 2005

### State variable code

```I have just checked in code which computes the state variable
equations for a linear electric circuit.
It was developed with the commercial macsyma, and will not work
with maxima unless the m..n operator is implemented which provides
a matlab sequence of integers from m thru n.
There is code which is used to deal with empty matrixes not being
compatible in one direction or another.  That is, it should be possible
to combine a matrix of zero columns and n rows, to a matrix of n rows,
and likewise with columns.
Dan Stanger
```
1 Aug 03:50 2005

### Re: State variable code

```m..n parses into

((mmatseq simp) \$m \$n)

which opens up a can of worms.

Can you do something else?
RJF

Donna and Dan Stanger wrote:

> I have just checked in code which computes the state variable
> equations for a linear electric circuit.
> It was developed with the commercial macsyma, and will not work
> with maxima unless the m..n operator is implemented which provides
> a matlab sequence of integers from m thru n.
> There is code which is used to deal with empty matrixes not being
> compatible in one direction or another.  That is, it should be possible
> to combine a matrix of zero columns and n rows, to a matrix of n rows,
> and likewise with columns.
> Dan Stanger
>
> _______________________________________________
> Maxima mailing list
> Maxima <at> www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
```
1 Aug 06:23 2005

### Re: State variable code

```Hi Dan,

> It was developed with the commercial macsyma, and will not work
> with maxima unless the m..n operator is implemented which provides
> a matlab sequence of integers from m thru n.

I find that infix ("..")\$ ".." (m, n) := makelist (i, i, m, n)\$ is enough in
this context, since m .. n is always evaluated with m and n bound
to integers.

Incidentally the Maxima parser assumes 1..n (e.g.) is 1.0 . n .
I've taken the liberty of putting spaces around ".." in state.mac.

I also fixed some case sensitivity problems in readfile.lsp
and tree.mac, and put a workaround for the lack of SUBSTRING

After making these changes, I find that properTree ("a.cir");
goes for a while and then runs into an error --
"Array pt_aJT has dimensions [3], but was called with [pt_MT[J]]",
not sure what that's about. Likewise b.cir and c.cir.

It is an interesting problem, I'm sure we can get this working quickly.

best,
Robert Dodier
```
1 Aug 10:08 2005

### Differentiate conditional expressions?

```Hi,

I'm trying to use Maxima for differentiation, but
don't know how to differentiate conditional expressions.
For example, in Mathematica I have such result:
In[1]:=D[Sin[x]*(If [x > 1, x, -x^2]), x]
Out[1]=Cos[x] If[x > 1, x, -x^2)] + If[x > 1, 1, -2 x] Sin[x]

and the same in Maxima fails with an error.
(%i1) diff(sin(x)*(if (x>1) then x else -x^2),x);
MACSYMA was unable to evaluate the predicate:
x > 1
-- an error.  Quitting.  To debug this try DEBUGMODE(TRUE);

Is there any way to differentiate such expressions in Maxima?

Michael
```
1 Aug 13:58 2005

### Array question

```Has anyone studied the internals of arrays enough to know
how one would implement a function which will tell if a particular
index is contained in a hashed array?  I suppose I could always
do a arrayinfo, and search thru the list linearly, but since the
arrays are probably implemented as a hash table, could it be
done with gethash?
Thanks,
Dan Stanger
```
1 Aug 17:21 2005

### Re: Differentiate conditional expressions?

```You might try using
sin(x)*( 'if (x>1) then 1 else 2);

(that is, quote the if),

Changing the setting of prederror might help, but I suspect not.

RJF

Michael Krasnyk wrote:

> Hi,
>
> I'm trying to use Maxima for differentiation, but
> don't know how to differentiate conditional expressions.
> For example, in Mathematica I have such result:
> In[1]:=D[Sin[x]*(If [x > 1, x, -x^2]), x]
> Out[1]=Cos[x] If[x > 1, x, -x^2)] + If[x > 1, 1, -2 x] Sin[x]
>
> and the same in Maxima fails with an error.
> (%i1) diff(sin(x)*(if (x>1) then x else -x^2),x);
> MACSYMA was unable to evaluate the predicate:
> x > 1
> -- an error.  Quitting.  To debug this try DEBUGMODE(TRUE);
>
> Is there any way to differentiate such expressions in Maxima?
>
> Michael
>
```

1 Aug 18:13 2005

### Re: Differentiate conditional expressions?

```
Maxima doesn't know the derivative of an 'if then' conditional.
I don't think there is an easy fix to this. A workaround is to
define a split-rule function using charfun  (defined in nummod.lisp;
get it from  http://www.unk.edu/facstaff/profiles/willisb/)

If you are not bothered by incorrect values for the
derivative at the the split point(s), you can try:

(%i2) gradef(charfun(p),0)\$                   <--- nummod doesn't define
the derivative of charfun

(%i3) f(x) := sin(x) * (x * charfun(x > 1) - x^2 * charfun(x <= 1));
(%o3) f(x):=sin(x)*(x*CHARFUN(x>1)-x^2*CHARFUN(x<=1))

(%i4) diff(f(x),x);
(%o4) cos(x)*(x*CHARFUN(x>1)-x^2*CHARFUN(x<=1))+sin(x)*(CHARFUN(x>1)-2
*x*CHARFUN(x<=1)) <-- wrong at 1.

Barton

>Michael Krasnyk wrote:
>
>> Hi,
>>
>> I'm trying to use Maxima for differentiation, but
>> don't know how to differentiate conditional expressions.
```

2 Aug 13:28 2005

### simple question i guess

```Hi guys,

here's something that i found out a while ago.. but have forgotten

How do i get the structured object for the representation of an expression?

i.e. a: 3+b
toLisp()

[something here]

(MPLUS 3 b)

I believe that's how it looks..?
Also if anyone knows a way to do this whilst staying in maxima.. i'm
using xMaxima if that makes a difference
Peace
Harry
```
2 Aug 15:09 2005

### Re: simple question i guess

```>>>>> "Harry" == Harry Kanda <lastrenshai <at> gmail.com> writes:

Harry> Hi guys,
Harry> here's something that i found out a while ago.. but have forgotten

Harry> How do i get the structured object for the representation of an expression?

Harry> i.e. a: 3+b
Harry> toLisp()

Harry> [something here]

Harry> (MPLUS 3 b)

Harry> I believe that's how it looks..?
Harry> Also if anyone knows a way to do this whilst staying in maxima.. i'm
Harry> using xMaxima if that makes a difference

Is this what you want?

(%i2) a:3+b;
(%o2) 				     b + 3
(%i3) :lisp \$%o2

((MPLUS SIMP) 3 \$B)
(%i3) :lisp \$a

((MPLUS SIMP) 3 \$B)

(%i3) to_lisp();
```

2 Aug 18:47 2005

### Re: Committing of patches and 5.9.2

```>>>>> "James" == James Amundson <amundson <at> users.sourceforge.net> writes:

James> On Mon, 2005-07-18 at 11:08 -0700, C Y wrote:
>> Seeing as we now have a number of significant patches that have been
>> outstanding for a while (for example the IO and prompt work) I would
>> like to suggest we consider branching cvs into a 5.9.2 tree and the
>> usual experimental tree.

James> I agree that a branch for 5.9.2 is in order.

I can create the appropriate branch and label if necessary.

However, someone needs to decide when the branch should take place
(now?), and we need to come up with an appropriate naming convention
for labels (tags) and branch names.

How about release-5_9_2-base for the base of the branch,
RELEASE-5_9_2-BRANCH for the branch label?  Various labels on the
branch will be release-5_9_2-<foo>.  (Branch names in upper-case, tags
in lower case.)

Ray
```

Gmane