wxMaxima: set formatting for rational powers - wxmaxima

I was wondering if there is some way to use texput to tell Maxima how to format powers when they are rational expressions.
e.g. I would like
tex1(2^(2/5));
> 2^{2 / 5}
instead of the default 2^{ \frac{2}{5} }.
Can this be done?

Related

Is there a null(empty) value in Numeric in labview?

I would like to enter empty in place of Zero in numeric. i dont want use strings.
In Numeric field we can enter only NAN or INF but i want enter Empty.
There is no such thing as an Empty value for floating-point numerics in LabVIEW, just as there is no such thing in C#, C++, Java, or C. They all use the same IEEE standard to define floating-point values.
I opened an idea for this on the Idea Exchange: Create an "Optional" input type wrapper in the style of C++17's std::optional.
It was largely rejected because it's not a suitably useful thing for general use, but some ideas as to how you might implement it yourself were discussed there (don't miss the second page).

OpenOffice Calc numeric formatting language

I am trying to display always-signed integers ('-1', '+4', etc: I'll even accept '+0') in OpenOffice Calc. I've had trouble finding exact information on the numeric formatting language used.
=TEXT(cellref;"#0")
doesn't display '+', and using "+#0" always displays '+' (it displays '-+3' for -3 in fact.)
Is there a format code for this, or do I have to write a function to handle the cases?
Here is a short but cryptic solution:
=TEXT(cellref;"\+#;\-#;0")
This is actually a three-part format code. It adds either a plus sign \+# for positive numbers, a minus sign \-# for negative numbers, or just a plain 0 for zeroes.
The syntax is described here: https://help.libreoffice.org/5.2/Common/Number_Format_Codes#Positive_and_Negative_Numbers
Another approach is to apply custom formatting, which is generally a good idea where numbers are involved, to make calculations with them easier:
"+"#;"-"#;0;General

How to write strict-greater? (-lesser?, -greater-or-equal?, -lesser-or-equal?)

Rebol and Red have a notion of the ordinary equal? function (offered infix simply as =) as being a sort of "natural equality". Hence it is willing to compare 1 = 1.0 even though one is an integer and the other a float... and to compare strings and characters case-insensitively by default.
The strict-equal? function is case-sensitive, demands things be the same datatype, and is tied to == as infix. (There is also a strict-not-equal? function as !==.)
However, the other comparison operators don't seem to have a strict variant. How would one implement a strict-greater? or a strict-lesser-or-equal?, etc. with the primitives in the box?
Behavior would be, for instance:
>> strict-lesser? "A" "a"
== true
As endo64 points out, strings are the stumbling block but since their components, characters, have the desired strict inequalities, the solution would seem to be to compare strings character by character ("lexicographically", if you wish). This goes for Rebol2, Rebol3 and Red alike.

How to format Standard ML print output?

I am trying to format some output in Standard ML. I need to display some real values as rounded to a certain decimal place, and I also need to be able to display some real values using scientific notation.
The signature for the print function is
val it = fn : string -> unit
which doesn't seem to allow for the use of formatting codes or any other parameters. I also haven't had any luck finding documentation online. Ideally I was hoping the print function in SML would have similar functionality to printf in C...
Standard ML is a statically-typed language. It's hard to make something like printf in a type-safe way.
The SML Basis Library contains some formatting operations for numbers. But to use them is relatively verbose and relatively difficult to figure out. For example, to format a real number into a string in scientific notation with 3 places after the decimal point, you can do something like this:
Real.fmt (StringCvt.SCI (SOME 3)) 4324423423.5; (* evaluates to string "4.324E9" *)
Ugly, right?
Some implementations offer other formatting methods. For example, SML/NJ has a Format structure that allows you to use a printf-style formatting string. However, the arguments must be wrapped according to their type:
Format.format "%.3e" [Format.REAL 4324423423.5]; (* evaluates to string "4.324e09" *)
Other SML implementations might have their own custom formatting functions.

Handling expressions in GMP

I introduced myself to the GMP library for high precision arithmetic recently. It seems easy enough to use but in my first program I am running into practical problems. How are expressions to be evaluated. For instance, if I have "1+8*z^2" and z is a mpz_t "large integer" variable, how am I to quickly evaluate this? (I have larger expressions in the program that I am writing.) Currently, I am doing every single operation manually and storing the results in temporary variables like this for the "1+8*z^2" expression:
1) first do mpt_mul(z,z,z) to square z
2) then define an mpz_t variable called "eight" with the value 8.
3) multiply the result from step one by this 8 and store in temp variable.
4) define mpz_t variable called "one" with value 1.
5) add this to the result in step 3 to find final answer.
Is this what I am supposed to be doing? Or is there a better way? It would really help if there was a user's manual for GMP to get people started but there's only the reference manual.
GMP comes with a C++ class interface which provides a more straightforward way of expressing arithmetic expressions. This interface uses C++ operator overloading to allow you to write:
mpz_class z;
1 + 8 * z**2
This is, of course, assuming you're using C++. If you are using C only, you may need to use the C interface to GMP which does not provide operator overloading.
Turns out that there's an unsupported expression parser distributed with GMP in a "expr" subdirectory. It's not part of GMP proper and is subject to change but it is discussed in a README file in that directory. It isn't guaranteed to do the calculation in the fastest way possible, so buyer beware.
So the user must manually evaluate all expressions when using GMP unless they wish to use this library or make their own expression parser.