1 Sep 12:15 2014

### Observation on segment

a) It doesn't work with subst as it picks only the last element in Segment and the whole list to be replaced it replaced by last element of segment.
subst(segment(a,b,c),t,[a,r,y,t]); => c

b) It can't be pushed on stack or consed.
i) imf:[]$push(segment(a,b,c),imf);; =>"Too many" arguments supplied to push(c,l); found: [a,b,c,imf] /*push evaluates before pushing*/ so, if one quotes it then, push('segment(a,b,segment(4,5),c),imf); => [segment(a,b,4,5,c)] ii) cons('segment(a,b,c),[a,r,y,t]); => [segment(a,b,c),a,r,y,t] /* no evaluation */ Without quote, cons(segment(a,b,c),[a,r,y,t]); => cons: "2nd "argument must be a non-atomic expression; found b c) w:segment(a,b,c) then [a,w,c] is [a,a,b,c,c] but llk:[g,h,j,k]$
for i:1 thru length(llk) do llk[i]:w;
llk is [segment(a,b,c),segment(a,b,c),segment(a,b,c),segment(a,b,c)] though expected was [a,b,c,a,b,c,a,b,c,a,b,c]

is it possible to address any of these issues ?

--
Regards,
Pankaj Sejwal
_______________________________________________
"The more I read, the more I acquire, the more certain I am that I know nothing.” -
Voltaire
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

30 Aug 15:47 2014

### Problem with bfloat

Hi everyone,

It seems there is a problem when I try to solve this:

eq : (40009998701367538133225879326610021275787734886557239554786867344479948809558936357308346039090053912747976315161807499191750731565057412193427526125139943062483732353369059902143126883533765447106960495457745029916237144786993152

*r6^4

-635169949538565681576982326160549436240883584439338432673525994990913080807950260860564946300674411801050636541037207842492256551427372153039955618506945366919221198007650439524793012000679388450770855239677149593727590431005134028800

*r6^3

+3773582944487787455830551492803259388211349008151340804131552138188093815385623045926247772506066538790464420557034914421623994643207226503772289573557474677051463750616572107720270280803074163957471223808122510464828502175400748646400000

*r6^2

-9948279623627893869859289209594080416041808413076560304612414814587118716991627738173731600116720301970551077968613578942034278006729503574412645544866229928697333169298505177614238627894769858092583862465518854305173865700801694924800000000

*r6

+9822922763110022709311739852374932544701082989677604695371182275825523040365218991617759102209164976234430910614344753842949200199390345412495844846726154719177727206292919047920074582348967155833787042629327031586343766578291539968000000000000)

/582076609134674072265625$trace(bfloat)$

solve(eq, r6);

1 Enter bfloat [0.0 + 1..#INF00e+000E+2678440]

2 Enter bfloat [0.0]

2 Exit  bfloat 0.0b0

2 Enter bfloat [1..#INF00e+000E+69]

bfloat: attempted conversion of floating-point infinity.

-- an error. To debug this try: debugmode(true);

------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

29 Aug 21:36 2014

### bug in gnuplot_defs.lisp, was: Maxima 5.34.0 release

Hello, thanks for the bug report.

Can someone fix it?

best,

Robert Dodier

---------- Forwarded message ----------
From: 本田康晃 <yasuaki.honda <at> gmail.com>
Date: Fri, Aug 29, 2014 at 9:34 AM
Subject: Re: [Maxima-discuss] Maxima 5.34.0 release
To: Robert Dodier <robert.dodier <at> gmail.com>

Dear Robert san,
I have tested 5.34.0 in my environment and have found a bug in
gnuplot_defs.lisp. When "ps_file" option is specified for plot, it
generates the following line:

set term postscript dashed eps color solid lw 2 size 16.4 cm, 12.3 cm font ",24"

in maxout.gnuplot file. This is erroneous as it specifies both dashed
and solid . This causes gnuplot runtime error and no ps file is
created!!

The fix is very simple: dashed should be removed.

Is there a way to fix this for 5.34.0?

Sorry that I noticed this in this last minute.

Yasuaki Honda, Chiba, Japan

2014-08-28 4:04 GMT+09:00 Robert Dodier <robert.dodier <at> gmail.com>:
>
> I've tagged 5.34.0 in Git and created tar.gz & rpms and uploaded them
> to the Sourceforge file manager: http://sf.net/p/maxima/files
> Changelog: https://sourceforge.net/p/maxima/code/ci/master/tree/ChangeLog-5.34
>
> If you can give it a try, that would be terrific.
>
> If someone can create a Windows installer, that would be wonderful.
>
> If there aren't too many complaints, I'll make a general announcement.
>
> best
>
> Robert Dodier
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> Maxima-discuss mailing list
> Maxima-discuss <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss

------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

28 Aug 23:03 2014

### Solving simultaneous equations by perturbation

This is just an email to say "Hey, that's easier than I
expected...". I've been messing around with some electronics and had
some ideas about making a current monitor to go with my (ancient) bench
power supply.

It turns out you really want several decades of resistors: in my case, I
wanted to measure low currents (100uA) up to reasonably high ones
(3A). I decided to use six shunt resistors, with values

0.004, 0.4, 4, 40, 400, 4000 ohms.

I'll ignore the problem of switching in different resistors, except to
say that you don't want to include the FET switches in the voltage
you're measuring because you don't have much control over the on
resistance of the transistor. So I came up with the topology that I've
sketched in the attached pdf (I only drew 3 resistors because I'm lazy,
and I threw it together quickly in Inkscape so please don't judge my
artistic skills too harshly!)

After staring at scribbled circuits on pieces of paper for a minute I
realised a problem: I don't want ridiculously large vertical resistors
(because of noise problems). Let's say the vertical resistors are each
maybe 100e3 ohms. But then suppose I'm using the 4k resistor: it's now
basically in parallel with five other 200k resistors, which will drop
the measured resistance significantly.

At this point, you might be wondering if I've sent this email to the
right list but, yes, that bit comes next!

I realised I could write down six simultaneous equations for r1
(nominally 0.004 ohm) to r6 (nominally 4000 ohm) and solve them. After a
couple of false starts, I wrote this code to generate the simultaneous
equations:

par(x,y) := x*y/(x+y);

partitions_1n (lst) :=
block([acc: [], before: []],
while not(emptyp(lst)) do (
acc: cons([first(lst),
append(reverse(before), rest(lst))], acc),
before: cons(first(lst), before),
lst: rest(lst)),
reverse(acc))$res_net_eqn (pair, stopper) := block([nominal: first(pair), lh, rh], lh: if not (emptyp (second (pair))) then ratsimp(par(1/lsum(1/(2*stopper + first(eqn)), eqn, second(pair)), first(nominal))) else first(nominal), rh: second(nominal), num(lh) = rh * denom(lh))$

res_net_eqns (nominals, stopper) :=
makelist(res_net_eqn(pair, stopper),
pair, partitions_1n(nominals));

eqns: res_net_eqns([r1=4/100,r2=4/10,r3=4,r4=40,r5=400,r6=4000], 1/G)$(For an explanation of partitions_1n, skip to the end) Here "G" is the conductance of one vertical resistor. The resulting equations are a bit unpleasant. For example: (%i44) first(eqns); (%o44) r1*r2*r3*r4*r5*r6*G^5+((((2*r1*r3+2*r1*r2)*r4+2*r1*r2*r3)*r5 +2*r1*r2*r3*r4) *r6 +2*r1*r2*r3*r4*r5) *G^4 +(((4*r1*r4+4*r1*r3+4*r1*r2)*r5 +(4*r1*r3+4*r1*r2)*r4+4*r1*r2*r3) *r6 +((4*r1*r3+4*r1*r2)*r4+4*r1*r2*r3)*r5 +4*r1*r2*r3*r4) *G^3 +((8*r1*r5+8*r1*r4+8*r1*r3+8*r1*r2)*r6 +(8*r1*r4+8*r1*r3+8*r1*r2)*r5 +(8*r1*r3+8*r1*r2)*r4+8*r1*r2*r3) *G^2 +(16*r1*r6+16*r1*r5+16*r1*r4+16*r1*r3+16*r1*r2)*G +32*r1 = ((((((r2+r1)*r3+r1*r2)*r4+r1*r2*r3)*r5+r1*r2*r3*r4)*r6+r1*r2*r3*r4*r5)*G^5 +((((2*r3+2*r2+4*r1)*r4+(2*r2+4*r1)*r3+4*r1*r2)*r5 +((2*r2+4*r1)*r3+4*r1*r2)*r4+4*r1*r2*r3) *r6 +(((2*r2+4*r1)*r3+4*r1*r2)*r4+4*r1*r2*r3)*r5+4*r1*r2*r3*r4) *G^4 +(((4*r4+4*r3+4*r2+12*r1)*r5+(4*r3+4*r2+12*r1)*r4+(4*r2+12*r1)*r3+12*r1*r2) *r6 +((4*r3+4*r2+12*r1)*r4+(4*r2+12*r1)*r3+12*r1*r2)*r5 +((4*r2+12*r1)*r3+12*r1*r2)*r4+12*r1*r2*r3) *G^3 +((8*r5+8*r4+8*r3+8*r2+32*r1)*r6+(8*r4+8*r3+8*r2+32*r1)*r5 +(8*r3+8*r2+32*r1)*r4+(8*r2+32*r1)*r3 +32*r1*r2) *G^2+(16*r6+16*r5+16*r4+16*r3+16*r2+80*r1)*G+32) /25 So I wasn't that surprised when shoving them straight into Maxima's solve() function wasn't particularly successful - I managed to warm the room up, but didn't achieve much else... (If you're a proper analyst or physicist, you might want to avert your eyes at this point: I'm far more comfortable doing algebra, so this might be painful to watch) Of course, then I realised that G is small. If I were a proper physicist, I'd rescale to make it a dimensionless quantity, but I'm feeling lazy and I've been at work all day. So, hmm. Perturbation theory. Can't be that hard, right? And with Maxima it turns out this problem is quite easy! simple_soln_p (soln, vars) := is ((length (soln) = 1) and setify(map(lhs, first(soln))) = setify(vars))$

flip_lists (lsts) := args (transpose (apply (matrix, lsts)))$taylor_stratify_one (expr, x, x0, order) := block ([expansion: taylor(expr, x, x0, order), pieces], pieces: makelist (x^n*coeff (expansion, x, n), n, 0, order), if not (equal (expansion, apply("+", pieces))) then error ("Couldn't stratify expression") else subst(1, x, pieces))$

taylor_stratify_eqns (eqns, x, x0, order) :=
flip_lists (makelist (taylor_stratify_one(eqn, x, x0, order), eqn, eqns))$perturb_solve(eqns, vars, eps, order) := block([newterms: makelist([v, makelist(gensym()*eps^k, k, 0, order)], v, vars), newvars, newvar_subst, neweqs], newvar_subst: makelist(first(pair) = apply("+", second(pair)), pair, newterms), neweqs: subst(newvar_subst, eqns), /* newvars are grouped by order, not original variable */ newvars: flip_lists (subst(1, eps, map (second, newterms))), block([strata: taylor_stratify_eqns (neweqs, eps, 0, order), known: []], for pair in flip_lists([strata, newvars]) do block([stratum, these_vars, rewritten, soln], [stratum, these_vars]: pair, rewritten: subst(known, stratum), soln: solve(rewritten, these_vars), if not (simple_soln_p (soln, these_vars)) then error("Can't solve ", rewritten, "for variables ", these_vars, ". Got: ", soln), known: append(known, first(soln))), subst(known, newvar_subst)))$

The "stratify" stuff uses taylor() to expand an expression in powers of
some variable, then collects coefficients for the different orders. Then
perturb_solve expands the variables in eps, stratifies the resulting
equation in terms of powers of eps and then solves a layer at a time,
From order zero upwards. I suspect there are equations where this
strategy fails miserably, but it turns out this isn't one of them.

And now to actually run the code:

(%i48) subst(1/100e3, G,
perturb_solve (eqns, [r1, r2, r3, r4, r5, r6], G, 1));
Evaluation took 0.0720 seconds (0.0730 elapsed) using 28.288 MB.
(%o48) [r1 = 0.04000004,r2 = 0.400004,r3 = 4.0004,r4 = 40.04,r5 = 404.0,r6
= 4400.0]

"First order?", I hear you scoff. So:

(%i49) subst(1/100e3, G,
perturb_solve (eqns, [r1, r2, r3, r4, r5, r6], G, 5));
Evaluation took 0.6480 seconds (0.6470 elapsed) using 295.398 MB.
(%o49) [r1 = 0.04000003980823639,r2 = 0.400003980860735,
r3 = 4.000398123173552,r4 = 40.03984945656259,r5 = 404.0224806732696,
r6 = 4444.219040588743]

Awesome!

Anyway, if anyone is still reading

(1) From bitter experience, I know that programming in Maxima is rather
difficult if you're trying to make robust code. But just hacking
something together is pretty easy. I wrote all the stuff above in
about 2 hours. (And was making up the maths as I went along:
someone who actually knew what they are doing would have been much
quicker)

(2) When writing code like this, my preferred approach is to sprinkle
print() statements liberally and then run it on small
examples. Most mistakes will give print-outs that are "clearly
wrong". (You can delete the print calls before you show anyone else
and pretend it worked first time...)

(3) The "flip_lists" function is kind of cute. I started writing a
zip() function and suddenly realised it's just matrix
transposition!

(4) It's worth indenting the code carefully. Maxima's syntax eschews
props for the weak-minded like curly braces (Bah! C++! Trivial!)
and has rather unhelpful syntax error messages when you get it
wrong. So make it as difficult to get wrong as possible.

(5) My partitions_1n function is really ugly. What it does is give you
all the ways of partititioning a list into "1 and n". That is

(%i50) partitions_1n([1,2,3,4]);
(%o50) [[1,[2,3,4]],[2,[1,3,4]],[3,[1,2,4]],[4,[1,2,3]]]

I couldn't think of a better way to express it than this
though. Anyone got a prettier version?

I hope this post was interesting / amusing for someone. The code was
definitely fun to write, and it answered a question I actually wanted to

Rupert


Attachment (shunt.pdf): application/pdf, 23 KiB
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

28 Aug 14:01 2014

### Mathematica style Pattern matching

Hi,
I made some investigation into how Mathematica's pattern matcher might be working and I have some preliminary results to share and discuss.

One random example is,
disect([___c1,___c,__b1,__b,_a1,_a],[1,2,3,4,5,6,7,8,9]

=>[[___c1,[]],[___c,[]],[__b1,[1]],[__b,[2],[3,4,5,6,7]],[_a1,[8]],[_a,[9]]]

If the rest entries for every sublist are consed, it will be reduced to same representation as Mathematica as,

[[___c1,[]],[___c,[]],[__b1,[1]],[__b,[2,3,4,5,6,7]],[_a1,[8]],[_a,[9]]] which is trivial to achieve.

I found all results to be consistent. It works fine in case of nested sublists also. It works exactly as Mathematica's list segregation method.

I have maintained notes here(in a fictitious Maxima journal !) which I will improve over time as I progress,

Next from here :
a) Mathematica allows nested pattern matching as,
{{1, 2, {3, 4, 5}, 7}, {11, 12, {13, 14, 15}, 17}} /. {a__, {b_, c__}, d__} :> {{a}, {b}, {c}, {d}}
=> {{{1, 2}, {3}, {4, 5}, {7}}, {{11, 12}, {13}, {14, 15}, {17}}}

c) One should be able to test the constraints on various patterns like,
{{1, 2, {3, 4, 5}, 7}, {11, 12, {13, 14, 15},
17}} /. {a__, {b_, c__}, d__} /; (d < 10) :> {{a}, {b}, {c}, {d}}
=> {{{1, 2}, {3}, {4, 5}, {7}}, {11, 12, {13, 14, 15}, 17}}

c) Mathematica allows naming patterns as,
{1, 2, {3, 4, 5, 6}, 7} /. {a__, k : {b_, d__, e_}, f___} :> k
=> {3, 4, 5, 6}

And many more things. I tested it against huge set of patterns and input and after removing some bugs, I think I am getting consistent answer.

If someone can finds any bug, please share. If all looks fine, I will experiment with lisp.

Comments and suggestions are most welcome.

--
Regards,
Pankaj Sejwal
_______________________________________________
"The more I read, the more I acquire, the more certain I am that I know nothing.” -
Voltaire
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

27 Aug 21:33 2014

------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

27 Aug 21:04 2014

### Maxima 5.34.0 release

I've tagged 5.34.0 in Git and created tar.gz & rpms and uploaded them
to the Sourceforge file manager: http://sf.net/p/maxima/files
Changelog: https://sourceforge.net/p/maxima/code/ci/master/tree/ChangeLog-5.34

If you can give it a try, that would be terrific.

If someone can create a Windows installer, that would be wonderful.

If there aren't too many complaints, I'll make a general announcement.

best

Robert Dodier

------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/

27 Aug 18:37 2014

### Error message

In two different environments, but not in a third, I have trouble processing the results of an
interpolation function. Details follow.

The following set of commands defines relevant parameters and creates the data set data1, using rk.

D:10.1$gamma:0.25$ c:gamma*D^2$m0:2.8e6$
GM:3.99e14$R:6.371e6$ vex:2500$tf:160$ mf:6e5$k:(m0-mf)/tf$
data1:     rk([v,-GM/(R+y)^2 + (k*vex-c*v^2)/(m0-k*t)],
[y,v], [0,0],[t,0,tf,0.1])$These two commands indicate that the process is working so far: length(data1); data1[length(data1)]; yields 1601 [160.0,72144.23901861806,1003.632013888879] The following commands create a list of data points and a cubic spline interpolation function: yvt:makelist([data1[i][1],data1[i][2]],i,1,length(data1))$
load(interpol)$cspline(yvt)$ yc(x):=''%$The following four values suggest that the interpolating function works as expected: [yc(0), yc(1), yc(length(data1-1)/20), yc(length(data1-1)/10)]; results in [0,1.23341409037613,13637.9151382676,72244.57787162811] The list yvt can be graphed. I did so, using points( ) in draw. Trying to plot the function yc(x), however, does not work, either in plot or in draw. Here are the draw command and the error message. load(draw)$
wxdraw2d(explicit(yc(t),t,0,tf),xlabel="time (s)",
ylabel="height (m)")\$
yields
$Maxima encountered a Lisp error: Error in PROGN [or a callee]: Bind stack overflow. Automatically continuing. To enable the Lisp debugger set *debugger-hook* to nil.$

This occurs in the following two environments, but not in a third one, as noted below.

In Windows 7
build_info
("5.28.0-2","2012-08-27 23:16:48","i686-pc-mingw32","GNU Common Lisp (GCL)","GCL 2.6.8")

In Linux Mint
wxMaxima version: 13.4.0
Maxima version: 5.30.0
Maxima build date: 2013-07-24 06:48:36
Host type: i686-pc-linux-gnu
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.7

The error messages do not occur in this setting: Macintosh
wxMaxima 13.04.0 which uses Maxima version 5.30.0 and wxWidgets 2.8.12 with Lisp: SBCL 1.0.55.0-abb03f9

Wilson Mixon

------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/

27 Aug 05:41 2014

### imaxima LaTeX errors

I am running a fairly newly-minted Ubuntu 14.04, with TeXlive 2014 and maxima 5.32.1.  However, imaxima insists on giving me error messages:

(%i1) 1+1;

LaTeX error in: 2
(%i2)

This is usually caused by LaTeX not being able to find breqn.sty.  However, in my case breqn.sty is certainly installed, as kpsewhich confirms.

Any other ideas what might be causing this error?

Thanks,
Alasdair
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

27 Aug 00:19 2014

### feature request

Hi everybody,

Can it be possible to assign multiple variables from a function call like in Matlab?
Here is a typical declaration in Matlab

function [r1, r2]=F(a, b, c, d)

and then the use is
[a, b]=F(c, d, e, f)

Right now if I want to return multiple variables from a function I have to pack everything in a list (not bad) but then I  have to unpack also manually using a dummy variable.

best regards,

Dimiter

------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

26 Aug 15:58 2014

### Help with iMaxima

I am running maxima 5.31.2 on windows 7. I have installed all the required software like tex and gs etc. Now when I am executing commands on imaxima I am getting errors. Can someone tell me how to troubleshoot the problem. Here is the output of my iMaxima session.

Maxima 5.31.2 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1)
(%i1) g(x):=exp(-x^2);

LaTeX error in: g\left(x\right):=\exp \left(-x^2\right)
(%i2) integrate(g(x),x,minf,inf);

LaTeX error in: \isqrt{\pi}
(%i3)
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss


Gmane