# Tag Info

## Hot answers tagged conversion

12

data = FinancialData["SPY", "Jan. 1, 2011"] /. {d_List, v_} :> {AbsoluteTime@d, v}; model = a x^4 + b x^3 + c x^2 + d x + e; fit = FindFit[data, model, {a, b, c, d, e}, x] modelf = Function[{x}, Evaluate[model /. fit]] Plot[modelf[x], {x, Min@data[[All, 1]], Max@data[[All, 1]]}, Epilog -> Map[Point, data]] Edit Better (tick labels showing dates) ...

11

Nested WolframAlpha approach, showing the intermediate steps: numberString[a_, k_: 10] := FixedPointList[ StringReplace[#, b : (DigitCharacter ..) :> WolframAlpha["spell " <> b, {{"Result", 1}, "Plaintext"}]] &, a, k] numberString["123456"] (* ==> {"123456", "123 thousand and 456", "one hundred twenty-three \ thousand and ...

9

Messy but a working method inWords[n_] := Module[ {r, numNames = {"", " one", " two", " three", " four", " five", " six", " seven", " eight", " nine"}, teenNames = {" ten", " eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen"}, tensNames = {"", " ten", " twenty", " ...

9

I've got my own package that I've used for a few years to generate LaTeX from Mathematica. All the labs on my Mathematica course page were produced with this package. Here's a handout on probability theory for Calc II students that was produced by the package. Unfortunately, it's not at all polished and really not usable by anyone but me. I can present ...

8

You can use the Range function in this way: Range[1, 2, 0.1] to get {1.,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.} If the problem is how to pass the parameter a you can use: 1- Using Apply. a = {1, 2, 0.1} Range@@a The Apply operator (@@) "decapitates" the List head from list a and changes it by Range. 2- Using Sequence a = {1, 2, 0.1}; ...

8

In Mathematica 8 you can use free form input : = Spell 15 and you get "fifteen" Or just write = thirty and you obtain 30 Since for larger numbers this approach yields expressions like {number words number, _ } one could nest this arbitrarily to obtain expressions containing only words. In fact, it is sufficient to nest only two times. For ...

8

This seems to work on my system at least, but as Mr.Wizard said it might be system dependent lineHeight = 1.5; conversion = 10;(*magic number*) scrollToThis = 80; paneHeight = 200; pos = (scrollToThis - 1/2)*lineHeight*conversion - paneHeight/2; Framed[ Pane[ Grid[List /@ data, Frame -> All, ItemSize -> {5, lineHeight}, ...

6

num = 1234567891234567899; triples = Reverse /@ Reverse@Partition[Reverse@IntegerDigits[num], 3, 3, 1, 0]; threePowers = {"septillion", "sextillion", "quintillion", "quadrillion", "trillion", "billion", "million", "thousand", ""}; singleRules = {0 -> "", 1 -> "one", 2 -> "two", 3 -> "three", 4 -> "four", 5 -> "five", 6 -> ...

6

This solution is similar in spirit to Prashant's. Though not particularly elegant, I avoid any calls to W|A and any other form of internet connectivity. Further down the post I also provide a solution to the inverse problem of returning the number when given English words. numberform[n_]:=With[{id=IntegerDigits@n}, ...

6

Update As @VCL pointed out in his comment, just exporting a list of graphics does not work since the braces and commas of the list a exported as well. Additionally, the pdf is one single page. Here is an updated approach, which takes all imported pdf-pages and inserts them into a new notebook where every page is separated by a pagebreak. The resulting pdf ...

6

It seems that every time you open a new cell with no style, that is "", it automatically puts the span tag to it. To to avoid this we can use this rule: "ConversionRules" -> { "" -> {"", ""} } So now, evaluating ExportString[ Cell[TextData[{"This is an equation: ", Cell[BoxData[ FormBox[RowBox[{RowBox[{"f", "(", "x", ...

5

You can access many different font characteristics via CurrentValue. Here is an approximation to convert between ItemSize and ImageSize: itemSize = {10, 10}; Overlay[{ Grid[ {{"Sample", "Text"}}, Frame -> All, Spacings -> {0, 0}, ItemSize -> itemSize, Alignment -> {Left, Center}], Row[{ Framed["Sample", ImageSize -> ...

4

It's not really the done thing to answer a question you've set a bounty on, but here is an explanation of why Mike's answer isn't quite right. The first point to note is that item sizes include the width of frames, so one needs to allow for the thickness of the frames in the ImageSize option for the second grid (thus the +2 in the option since FrameStyle has ...

4

This looks like the Raw Input Form (one of the Convert To options in the Cell menu) of a string with formatted elements. Also, if you take a formatted string like the first code block in your question and append it with //ToBoxes, or if you select Show Expression in the Cell menu, you get something similar to the second block. Append //Normal to the second ...

3

For the older "Units" package units are just symbols which are multiplied to numbers. If you want to get rid of them, just replace them with 1: Convert[0.05263, Percent] /. Percent -> 1 In such cases, it is often very useful to use InputForm or even FullForm to explicitly check with what you are dealing and what is returned, e.g.: Convert[0.05263, ...

3

... you can also use ReplaceAll: a={1,2,.1}; a /. List->Range (* ReplaceAll *) (* {1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.} *) or, ReplacePart: ReplacePart[a, 0 -> Range] (* {1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.} *) or, set Part zero to Range (re-assign head): b=a; b[[0]]=Range;b

3

I used the following to solve Problem 17 from Project Euler (hint hint). It's working on numbers up to 1000, but the grammar of larger numbers is trivial compared to small numbers and should easily be able to be implemented. Usage: numberToWord /@ {14, 271, 944} {"fourteen", "two hundred and seventy-one", "nine hundred and forty-four"} Source: ...

3

Using the definition of cell as in the question we can define: CellToTeX[cell_] := Module[{str}, str = ConvertTeXBoxesToTeX@Replace[cell, {"\[AlignmentMarker]" -> "&"}, {-1}]; StringReplace[str, {"\\&" -> "&", "array" -> "aligned"}] ] Then when we use it we obtain: CellToTeX[cell] \begin{aligned}{c} a+b+c&=d \\ ...

2

You should be able to turn this off globally for your current kernel session by using a variant of the solution posted by Albert Retey to an earlier question of mine: SetOptions[\$FrontEnd, FormatType :> (Style[TraditionalForm[##],SingleLetterItalics -> False] &)] You might also want to set the same for Graphics, depending on what you are ...

2

The span tag does nothing unless you specifically style it as it is designed to The <span> tag is used to group inline-elements in a document. The <span> tag provides no visual change by itself. The <span> tag provides a way to add a hook to a part of a text or a part of a document. Using css, you can hook on to that and ...

2

The fastest method keystroke-wise that I have found is: Create new empty cell Press Ctrl+Shift+E to get Cell[BoxData[""], "Input"] Paste your expression into that one replacing the "" inside of BoxData. Press Ctrl+Shift+E again. Alternatively, plaste your expression into this and evaluate: FrontEndExecute@FrontEndCellPrint[ (* expression here *) ]

2

Taking the last line of your question literally: a = {1, 2, 0.1}; Row[Range @@ a, ","] 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2. Also, to illustrate an alternative data format: a = Sequence[1, 2, 0.1] Range[a] {1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.}

1

You could do something like this: toBaseString[n_?NumericQ, b_Integer?Positive] := First @ StringSplit @ ToString @ BaseForm[n, b] toBaseString[365.7, 5] "2430.32222" I missed that you didn't want strings. Perhaps you want this?: toBasePlain[n_?NumericQ, b_Integer] /; 11 > b > 0 := N @ FromDigits @ RealDigits[n, b] toBasePlain[365.7, ...

Only top voted, non community-wiki answers of a minimum length are eligible