Online Algebra Calculator
Many of users do not use powerful Maxima computer algebra system for systematic work, but for ad hoc algebraic calculations – equations, functions, matrixes, etc. only. To do this job, it is not useful to download the whole application from a web site.
Function: printf (<dest>, <string>)
![Printf Example f(a):= a[1] + a[2]*(2**32) + a[3] *(2**(32*2)) + a[4] *(2**(32*3)) + a[5] *(2**(32*4)) + a[6] *(2**(32*5));
f2(a):= f(a[1]) + f(a[2])*(2**(32*5*1))+ f(a[2])*(2**(32*5*3));
b:[[1,3408,1,1507328,0,0],[1,0,1,1507328,0,0],[1,2204,1,0,0,0]];
printf(true,"~x",f2(b));](http://maxima-online.org//plot.html?g=i-692690931.png&t=img&db=r-410148111)
Function: printf (<dest>, <string>, <expr_1>, ..., <expr_n>) Makes the Common Lisp function FORMAT available in Maxima. (From gcl.info: "format produces formatted output by outputting the characters of control-string string and observing that a tilde introduces a directive. The character after the tilde, possibly preceded by prefix parameters and modifiers, specifies what kind of formatting is desired. Most directives use one or more elements of args to create their output.")
The following description and the examples may give an idea of using printf. See a Lisp reference for more information.
~% new line ~& fresh line ~t tab ~$ monetary ~d decimal integer ~b binary integer ~o octal integer ~x hexadecimal integer ~br base-b integer ~r spell an integer ~p plural ~f floating point ~e scientific notation ~g ~f or ~e, depending upon magnitude ~h bigfloat ~a uses Maxima function string ~s like ~a, but output enclosed in "double quotes" ~~ ~ ~< justification, ~> terminates ~( case conversion, ~) terminates ~[ selection, ~] terminates ~{ iteration, ~} terminates
Note that the selection directive ~[ is zero-indexed. Also note that the directive ~* is not supported.
(%i1) printf( false, "~a ~a ~4f ~a ~@r",
"String",sym,bound,sqrt(12),144), bound = 1.234;
(%o1) String sym 1.23 2*sqrt(3) CXLIV
(%i2) printf( false,"~{~a ~}",["one",2,"THREE"] );
(%o2) one 2 THREE
(%i3) printf(true,"~{~{~9,1f ~}~%~}",mat ),
mat = args(matrix([1.1,2,3.33],[4,5,6],[7,8.88,9]))$
1.1 2.0 3.3
4.0 5.0 6.0
7.0 8.9 9.0
(%i4) control: "~:(~r~) bird~p ~[is~;are~] singing."$
(%i5) printf( false,control, n,n,if n=1 then 0 else 1 ), n=2;
(%o5) Two birds are singing. If <dest> is a stream or true, then printf returns false. Otherwise, printf returns a string containing the output.
There are also some inexact matches for printf. Try ?? printf to see them.
(%o1) true (%i2)