Tag Info

New answers tagged

4

It seems you have to evaluate Return[]. Strange that there is no command-button for this action. F5 also works. http://reference.wolfram.com/mathematica/tutorial/Dialogs.html


0

Prompted by comments conversation with Mr. Wizard, a routine I use: findMultiPosXX[list_, find_, allowBits_: False, skipCands_: True] := Module[{f = DeleteDuplicates[find], o, l, oo, bitmax = 20, cands, dims}, If[allowBits && Length@f <= bitmax, With[{r = If[Length@(dims = Dimensions@list) == 1, Range@Length@list, ...


7

The reason your original code fails is that the TreeFrom object is only formatted as Graphics object, meaning that it converted for display rather that as part of the normal evaluation sequence. You can convert to and from box form to recover your Graphics object: tf = TreeForm[a + b^2 + c^3 + d]; gr = tf // ToBoxes // ToExpression gr /. (x_Framed ...


2

Building on swish's answer, I would write nodes = Cases[Network`GraphPlot`ExprTreePlot[a + b^2 + c^3 + d], _Framed, ∞]; This has the advantage of allowing you to work with the individual node objects; for example: nodes[[2]] If want output that looks like your printed output just evaluate Column@nodes


4

From this answer Network`GraphPlot`ExprTreePlot[a+b^2+c^3+d] /. (x_Framed :> Print[x])


3

Oska nailed it in the comments before me The trick here is to evaluate the integral only once. In your code it is being evaluated once for every point. You can evaluate the following Integrate[Sin[((1 + 1/2) x)] (1/(2 Sin[(x/2)]) - 1/x), {x, 0, t}] The outcome of this is ConditionalExpression[1/2 (t + 2 Sin[t] - 2 SinIntegral[(3 t)/2]), t \[Element] ...


6

Here is one way to define such a macro: SetAttributes[withCurrent, HoldAll] withCurrent[{v:(_Symbol...)}, body_] := Replace[Hold[v], s_ :> (s = s), {1}] /. _[a___] :> With[{a}, body] withCurrent is given the HoldAll attribute to delay the evaluation of the arguments until after we have had a chance to process them. It wraps the supplied sequence ...


3

The key is to use the injection pattern. SetAttributes[WithCurrent, HoldAll] WithCurrent[list_, delayeddefs___] := With[{ls = Replace[Map[Hold, Replace[Hold@list, Hold[{x___}] :> Hold[x]], 1], Hold[x_] :> (x = x), -1]}, Hold[With[ls, delayeddefs]] /. Hold[x___Set] :> {x}] // ReleaseHold a = 1; b = 2; c = 3; WithCurrent[{a, b}, ...


1

In case you want Mathematica to suppress on the fly simplification and having slots (#) involved, you might consider using Defer: Defer@Integrate[x^# Exp[-x], {x, 0, 1}]&/@Range[2]


4

I think the most straight forward would be to use Mathematica packages and importing the definitions in that notebook using the function Get as Szabolcs mentioned in the comments. I suggest that you have a closer look at the documentation on how to set up packages in Mathematica. Th principle is quite simple to understand. Here is a small example of how ...


1

In the first notebook: Add[x0_, y0_] := Module[{x = x0, y = y0}, x + y] Save["myFunction", Add] Or put your first notebook in to C:\Documents In the second notebook: Get["myFunction"] Add[1, 2]


1

I have improved J. M.'s version of walkD by adding error handling. I have also added walkInt that works like walkD except for integration. Code: Format[d[f_, x_], TraditionalForm] := ( paren = MatchQ[f,Plus[_,__]]; boxes = RowBox[{f}]; If[paren, boxes = RowBox[{"(", boxes, ")"}] ]; boxes = RowBox[{FractionBox["\[DifferentialD]", ...


3

The only thing wrong with your code is that Series doesn't return an expression suitable for evaluation at specific values of the expansion variable. You first have to convert the SeriesData object to a normal expression using Normal. This is the only change needed: i1[ϵ_] = Normal[Series[i[ϵ], {ϵ, 0, 1}]]; With this, the integration works as expected: ...


1

As Boson suggested, HoldForm and ReleaseHold can be pressed into service to accomplish what you ask. Here is how you can use them. ySq[x_] := Module[{y}, Row[{"y = ", y = HoldForm[x^2], " = ", ReleaseHold[y]}]] Column[ySq /@ Range[5]] y = 1^2 = 1 y = 2^2 = 4 y = 3^2 = 9 y = 4^2 = 16 y = 5^2 = 25 ySq can serve as a model for defining other functions ...


1

I would recommend to look into new functions that are already available on Raspberry Pi and you have something to look forward to in a general future release: Activate, Inactive and Inactivate. They are a very powerful way to transform the code and expressions in the way you need. For example. f[x_] := Inactive[Power][x, 2] y == f[2] y == 2^2 y == ...



Top 50 recent answers are included