The Stack Overflow podcast is back! Listen to an interview with our new CEO.

# Tag Info

1

You can use NSolve instead of Solve followed by N: NSolve[{x + 1/x == y - 1/y, x^2 + 1/x^2 == y^2 - 1/y^2}] {{x -> -0.353553 - 0.935414 I, y -> 0.707107}, {x -> -0.353553 + 0.935414 I, y -> 0.707107}, {x -> 0.353553 - 0.935414 I, y -> -0.707107}, {x -> 0.353553 + 0.935414 I, y -> -0.707107}} Or, you can use FullSimplify instead of Simplify: ...

1

Thank you Xminer for a hint. The solution is this: {{PDF[ DiscreteMarkovProcess[1, P][Infinity], 1],PDF[ DiscreteMarkovProcess[1,P][Infinity], 2], ...}} // MatrixForm where P is Markov transition matrix and the second PDF argument is the value of Boole.

1

A (much slower) procedural method. First we find the number of digits of 123...(n-1)n. numlength[n_] := With[ {pow = Floor@N@Log10[n]}, Range[pow].(9*10^Range[0, pow - 1]) + (pow + 1) (n - 10^pow + 1) ] Here pow = Floor@N@Log10[n] gives the order of magnitude (OoM) of n, Range[pow] and (pow + 1) gives the number of digits in each OoM and the last OoM, ...

7

The number you are constructing is related to the base 10 Champernowne constant, except that the Champernowne is a real number that starts with 0.123... while your "number" is an integer with an infinite number of digits. In Mathematica, the Champernowne constant in base 10 is given by ChampernowneNumber[]. To get the 10,000 digit, just use RealDigits: ...

1

If your ultimate goal is implementation of Romberg Integration Method, here is straightforward way to do it usingTable ClearAll["Global*"] f[x_] := 1/x romberg[a_, b_, n_] := Module[{}, h[j_] := (b - a)/2^j; R[0, 0] := h[1] (f[a] + f[b]); R[j_, 0] := 1/2 R[j - 1, 0] + h[j] \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$i = 1$$, SuperscriptBox[$$2$$, \(j - ...

2

Update: an alternative approach using FoldList: nla = FoldList[Function[{x, y}, ((4 y - x)/3)] @@@ Partition[#, 2, 1] &, T, Range[Length[T] - 1]]; TeXForm @ Grid[Flatten /@ PadLeft[nla]] \$\begin{array}{ccccc} 0.75 & 0.708333 & 0.697024 & 0.694122 & 0.693391 \\ 0 & 0.694444 & 0.693254 & 0.693155 & 0.693148 \\ 0 &...

11

This is a precedence issue. "fa" -> (# + 1/2) & is interpreted as ( "fa" -> (# + 1/2) ) &. Write "fa" -> ( (# + 1/2) & ) instead.

3

Maybe you can use the fact that TraditionalForm by default interprets parentheses as function calls: fromCString[s_String] := ReplaceAll[ ToExpression[s, TraditionalForm, Defer], { sqrt -> Sqrt, sqr -> square } ] Then: fromCString["sqrt(sqr(x)+y*z)"] Sqrt[square[x] + y z]

6

There is a handy package, Notation, built-in to Mathematica. With it, we can do the following: Needs["Notation"] Notation[ParsedBoxWrapper[RowBox[{"sqrt", RowBox[{"(", "x_", ")"}]}]] ⟹ ParsedBoxWrapper[SqrtBox["x_"]]] Notation[ParsedBoxWrapper[RowBox[{"sqr", RowBox[{"(", "x_", ")"}]}]] ⟹ ParsedBoxWrapper[...

Top 50 recent answers are included