Mathematica output formatting - wolfram-mathematica

How does Mathematica decide when to round numbers in its output? For example,
giving the input
250000.5
gives the output
2500001
While
25000.5
is indeed printed as
25000.5
N[] isn't helpful here either, I need to use NumberForm[] to get it to actually print 250000.5 as 250000.5
I'm a Mathematica newbie, and I'm sure its ridiculously easy to control this threshold for when it starts ignoring decimals in its output, but could somebody please point me in the right direction?

another option for you to try, you can go to options and change the default PrintPrecision from 6 to say 16, and now you will see that it will print what you typed above
after I changed that to 16 (click on the field itself, and type 16 into the field to replace the 6, and hit return), then

Nasser is correct that PrintPrecision is the right setting.
You have a number of options for its use. You can set it Globally or for the specific Notebook using the Options Inspector. You can also use it directly with Style:
Style[250000.5, PrintPrecision -> 10]
250000.5
You can set it temporarily for one session like this:
SetOptions[$FrontEndSession, PrintPrecision -> 10]
Finally you can set it using Style Sheets (select cell type Output).

In the default TraditionalForm and StandardForm output modes Mathematica only shows a certain number of most significant digits. You can use InputForm to get the full precision number.

Related

Highlight cell based on custom formula of conditional formatting

I will input numbers serially but not in consecutive cells, it would be random like this:
I want to highlight numbers from where the serial number is broken as shown (Since number 17 is missing so number 18 onwards all number are highlighted)
Please help me with a custom formula for the conditional formatting of this.
try this new approach:
=REGEXMATCH(A2&"", INDEX(TEXTJOIN("|", 1, "×",
SORT(IFERROR(1/(1/((IFERROR(SORT(UNIQUE(FLATTEN(IFERROR(SPLIT(A$2:A, ",")))))<>
SEQUENCE(MAX(FLATTEN(IFERROR(SPLIT(A$2:A, ","))))), TRUE))*
SEQUENCE(MAX(FLATTEN(IFERROR(SPLIT(A$2:A, ",")))))))), 1, 0))))
try:
=A2>INDEX(MAX(IFERROR((SEQUENCE(MAX(A$2:A))=SORT(A$2:A))*SEQUENCE(MAX(A$2:A)))))
update:
=REGEXEXTRACT(A2&"", "\d+,?")*1>INDEX(MAX(IFERROR((SEQUENCE(MAX(A$2:A))=
SORT(UNIQUE(FLATTEN(SPLIT(A$2:A, ",")))))*SEQUENCE(MAX(A$2:A)))))

View full contents of a matrix in Euler Math Toolbox

How to display all the numbers from a given matrix in Euler Math Toolbox? It doesn't seem to show more than 8 columns at a time, which isn't enough as I frequently need to view more than that.
Output I'm getting as of now:
The documentation says:
Large matrices or vectors might not print in full size. To change this, toggle the behavior with:
largematrices on
largematrices off
or use the operator showlarge.
showlarge random(10,10)
See:
showlarge (Basic Utilities)
The link in the above documentation link directs here:
function prefix showlarge (x$)
Prints large matrices in full.
By default EMT eclipses lines and rows of large matrices. This can be used to see the full matrix. If the parameter is a variable the variable name will be printed.
The default can be changed with largematrices on/off.
x=random(20,5); showlarge(x)
showlarge(random(20,5))
See:
largematrices (Euler Core),
show (Maxima Documentation)

AMPL, set 1..T is not working

The 1..T function is not working for me, and I don't know why. My code looks like this:
set TIME;
data;
set TIME = 1..8760 by 3;
display TIME;
Here I want it to display 1, 4, 7, 10, and so on, but it just goes 1..8760 by 3. How can I fix this so that I don't have to write 8,760 different numbers?
Thankful for answers!
I don't find any error in your code. I tried in my AMPL IDE:
AMPL IDE
I suppose that when you write "data" is that your code is in the .dat file and when you write "display" is your .run file
What are you using to write your model?? NEOS SERVER or the IDE??
Regards!
Try deleting the first two lines of your code.
It looks as if the format you're using to specify TIME only works in "model" mode; in "data" mode, the same text is interpreted as declaring a set of literals "3", "by", and "1..8760". (Quick test: if you type display card(TIME); you get a value of 3, telling you that there are exactly 3 members in this set.)
Section 5.2 of the AMPL Book recommends using a "x..y by z" type declaration in the model (with x, y, z as declared params) and then specifying values for x, y, z in the data.
Note that starting at 1 and increasing in steps of 3 won't actually get to 8760 exactly, so you might want to change your start to 0 or 3, or your end to 8761, if you want equal gaps between the numbers.

Dangerous symbol names that begin with a lowercase letter

I am looking for a full list of dangerous symbol names that begin with a lowercase letter in Mathematica.
At this moment I know three such names: min, max and lim. These names appear in the LimitsPositioningTokens list and are being treated as operators at least when they are entered in the FrontEnd with a superscript:
In[3]:= Options[$FrontEnd,LimitsPositioningTokens]
Out[3]= {LimitsPositioningTokens->{\[Sum],\[Product],\[Intersection],
\[Union],\[UnionPlus],\[Wedge],\[Vee],lim,max,min,\[CirclePlus],
\[CircleMinus],\[CircleTimes],\[CircleDot]}}
For example, type in the FrontEnd the following (use Ctrl+^ for making superscript - it is important!):
In[1]:= max^n+4
(max^n+4)//HoldComplete//FullForm
Out[1]= 4 max^n
Out[2]//FullForm= HoldComplete[Times[Power[max,n],Plus[4]]]
You see that max^n+4 is interpreted as 4*max^n in this case.
Can anyone explain what LimitsPositioningTokens option really does?
Are there other dangerous symbols that begin with a lowercase letter in Mathematica?
I cannot confirm the problem you report. Besides, the tokens you've found seem to be strings rather than symbols.
This is on win7-64/M8.0.1, my wife's mac lion/M8 doesn't show it either.
The fact that they are strings seems to be consistent with the description on the doc page of LimitsPositioning
LimitsPositioningTokens is a Cell option which can be set to a list of
forms for which LimitsPositioning->True should be used.
All examples given there use strings.
Update to illustrate the point made in the comments below
This is with the standard LimitsPositioningTokens setting in $FrontEnd:
and this is with SetOptions[$FrontEnd, LimitsPositioningTokens -> {}]:
Please note that the $FrontEnd setting with SetOptions is sticky. It is likely that yours isn't at default anymore. Use the option inspector to return LimitsPositioningTokens to its default value (search for LimitsPositioningTokens with Global Settings on and remove the cross next to the variable if there is any).

Java applet - Real-time textfield input verification

I'm trying to develop an input real-time verification on a textfield in a Java applet.
The idea would be to have an input field that, if empty, once the user clicks in it it would show something like "0,00". Once the user starts to press the keys, only numbers should be accepted, and it would start to fill the text like this (imagine I input the numbers:
1,2,3,4,5,6):
"0,01" -> "0,12" -> "1,23" -> "12,34" -> "123,45" -> "1.234,56".
If the field is not empty the user can change the values but there will always be a "," dividing the decimal numbers.
I've been able to allow only numbers to be accepted but how can produce this kind of behavior? I know this may be a very specific question but any links or examples would be much appreciated. Thank you.
You will have to provide an input handler, that not only filters the input, but also calls a preset callback (made by you), that will update the required field in the way you want it to be updated.
You can use some functions, that can format numbers, given a specific format.
Basically, just keep a count on number of digits, already input, then parse it as a plain integer then multiply it by a power of 10, derived from the format, in your example would be something like 10 raised to the power of (numberOfInputDigits -2).

Resources