Hi! I klicked on 'Discussion' so here is my question:
Is it possible to leave a for/do loop in case of a special condition? 'return' does not exit the loop. The loop runs always through the whole scope.
And second: I need a round function in Maxima. Floor and ceiling doesn't work for me. Is there someting i doesn't see?
Thanks Wolfgang
1. Non documented Maxima’s function round(x) rounds number x to integer.
2. If you need to round number x to n significant digits use simple one-line function roundn(x,n).
roundn(x,n):=block([p:10^(floor(log(abs(x))/log(10))-n+1)], 1.0*p*round(x/p))$
Test list [roundn(134,2),roundn(135,2),roundn(-135,2),roundn(.0135,2),roundn(-.0000135,2),roundn(2/3,2)]; returns [130.0,140.0,-140.0,0.014,-1.4*10^-5,0.67]
3. If you need to round to n significant digits not only numbers, but also lists of numbers, matrices with number elements, lists of matrices, matrices with list elements etc try more complex recursive function round_(x,n).
listmat(L):=block([x:matrix(L[1]),n:length(L)],if n>1 then for i:2 thru length(L) do x:addrow(x,L[i]),x)$
matlist(m):=block([x:[]],for i:1 thru matrix_size(m)[1] do x:append(x,[m[i]]),x)$
round_(x,n):=if numberp(x) then block([p:10^(floor(log(abs(x))/log(10))-n+1)],1.0*p*round(x/p)) elseif listp(x) then makelist(round_(x[i],n),i,1,length(x)) elseif matrixp(x) then listmat(makelist(makelist(round_(x[i,j],n),j,1,length(x[1])),i,1,length(x))) else x$
Test Examples: [round_(134,2),round_(135,2),round_(-135,2),round_(.0135,2),round_(-.0000135,2),round_(2/3,2)]; returns [130.0,140.0,-140.0,0.014,-1.4*10^-5,0.67]. round_([-123.44,2,2334,[1230,-76543],-0.000012345],2); returns [-120.0,2.0,2300.0,[1200.0,-77000.0],-1.2*10^-5]. round_([1235.0099,3,matrix([1234,5678],[90123,4567]),[2345,x]],2); returns [1200.0,3.0,matrix([1200.0,5700.0],[90000.0,4600.0]),[2300.0,x]].
P.S. listmat(L) converts a list of equal-length elements to a matrix. matlist(M) converts a matrix to a list of rows.
All above functions are written & tested using Maxima 5.13.0 with wxMaxima 0.7.3a interface.
I hope above will be helpfull.
Sergey
symbolic input
Hi,
first of all I have to say that Maxima with its great GUI wxMaxima is by far the best CAS out there - in my eyes. Really the only downer for me is that the input is not "symbolic". The output is displayed nicely through wxMaxima's own math display engine, but the input isn't. It would be much clearer and finding mistakes in the input would be much easier if the input would be worked up in the same way as the output is. E.g. if you set brakes in a wrong way, you would see it immediately.
Is there a simple way to modify Maxima to that effect?
Thanks, uxo
Bell sounds when pressing up-arrow in Input Box
After I disable the auto-matching parenthesis using edit->Configure, whenever I use the up arrow in the "INPUT" box on the main screen to recall a previous command, a bell chimes.
This is a minor thing, but a bit annoying since the only way around it right now is to mute all the sound on the workstation.
I am currently running 64 bit Windows Vista, but have encountered this on 32 bit Windows XP as well.
extrat result of system equation as a function ??!!
Hello,
I need some help .
I Do not found how to make a function of a result of linear equation depending of a parameter. here is a example :
f(x) should be a function of x depending of others constants but the behaviour is not the one i expected for.
What's wrong with my computation ?
Thanks for help.
/* example */ programmode:true; breakup:true; numer:false; debugmode:false; U1:1; U2:1; a:1; Z(x):=a*x; RRR1(x):=b*x+c; RRR2(x):=b*(l-x)+c; eq1:RRR1(x)*I1+Z(x)*I3-U1=0; eq2:Io1+I3-I1=0; eq3:RRR2(x)*I2+Z(x)*I3-U2=0; eq4:I3+Io2-I2=0; eq5:Io1+I2=0; eq6:Io2+I1=0; MAT:solve([eq1,eq2,eq3,eq4,eq5,eq6],[I1,I2,I3,Io2,Io1]); f(x):=part(MAT,1,1,2);
f(1); /* result is not a computation of f(1) */ RRR2(x)/(RRR1(x)*(RRR2(x)+x)+x*RRR2(x))
