# Tag Info

7

To expand my comment into an answer: HoldForm[X[x, y, z]] == X[x, y, z] // TraditionalForm $$X(x,y,z)=\left( \left\{ \begin{array}{cc} \frac{3}{4 \pi } & \sqrt{x^2+y^2+z^2}\leq 1 \\ 0 & \text{True} \\ \end{array} \right. \right)$$ But Mathematica decides it needs parentheses. I agree that this doesn't look ideal. There are a couple of ways ...

4

I'm going to guess at what the OP wants. This code should reproduce the problem as I see it. SetDirectory[NotebookDirectory[]] p = Plot[Sin[x], {x, 0, 4 Pi}] Export["test.m", p] RenameFile["test.m","test.txt"] The file "test.txt" is now a text version of a notebook file that has valid Mathematica code but an extension that will be misinterpreted by ...

1

Not sure chris has the right idea. I assume your file is not some exported data, strings, tables, etc. but rather a bunch of commands you basically want to execute from file, right? The Import command tends to work with the types of files produced by Export. It would probably treat your file as text. You can use the Read or ReadList commands. If you use ...

13

The problem relates to the granularity of MachinePrecision numbers. The number 70.329862 is represented as an integer times a power of 2: x0 = SetPrecision[70.329862, Infinity] (* 4949024067128413/70368744177664 *) (The denominator is 2^46.) The machine numbers near this number do not allow for the representation of 70.329862 with \$MachinePrecision ...

8

EDIT Input gets different rounding to machine-precision real if it's written in arbitrary precision! RealDigits[70.329862, 2] (* {{1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1}, 7} *) RealDigits[ SetPrecision[70.329862000000000000, ...

1

This change of behavior is not intentional, and will be fixed in the next release of Mathematica. It was, ironically, an unforeseen consequence of fixing another bug involving modifier keys. I regret the incomplete information given to you by Technical Support. They were answering the question of how to customize key bindings--a common request, but not one ...

3

The code as below can achieve the result that you need. Clear@t; mat = RandomInteger[{1, 10}, {20, 4}]; Evaluate[t /@ Range[Length@mat]] = mat Because of (=)Set has the attribute HoldFirst, I use the function Evaluate to evaluate first before proceeding with Set.

3

Perhaps this will work for you. Given a symbol, say t, and a matrix, say m, it will define a set of indexed variables t[1], t[2], ..., t[n], bound to the respective rows of m. SetAttributes[assign, HoldFirst]; assign[name_Symbol, matrix_List] := ( Clear @ name; Do[t[i] = matrix[[i]], {i, 1, Length@matrix}] ) Generate some data. SeedRandom[42]; m ...

Top 50 recent answers are included