Tag Info

New answers tagged

12

$ is probably the only non-alphanumeric ascii character without a special meaning in Mathematica and thus the only one you could use as a delimiter for various parts within a variable name. A warning is due: Because it is so unique, it is also used internally for the same purpose, e.g. Module and Unique will generate variable names ending in $+ an ...


8

If you make any assumptions you have to share them with Mathematica as well. For Example: Assuming[R > 0, FullSimplify[(R^3)^(1/3)]] (*R*) The default assumption is that all variables are complex. (As @J.M. noted in the comments).


5

It's just not always true that $(R^3)^{1/3} = R$. How about $R=i$, for example? N[(I^3)^(1/3)] (* Out: 0.866025 - 0.5 I *) If you expect this, you might have more luck with the real-valued CubeRoot function. For example: FullSimplify[CubeRoot[R^3]] (* Out: R *)


3

Here's something I found: With[{h := {x = 7, y = 8}}, Block[h, x y]] 56


1

var /: Block[var, code_] := Block[{x = 2, y = 3, z = 4}, code] So x = 100; Block[var, x + 2] (* 4 *)


1

The way I prefer is var := {x = 2, y = 3, z = 4} ReleaseHold[Hold[Block[var, x*y*z]] /. OwnValues[var]] x -> 24 -> x Or Apply[Block, Hold[var, x*y*z] /. OwnValues[var]] x -> 24 -> x For hVars = Hold[{x = 2, y = 3, z = 4}]; We can do ReleaseHold[Hold[Block][hVars, Hold[x*y*z]]] x -> 24 -> x


5

This could be another case for the injector pattern: var = Hold@{x = 2, y = 3, z = 4} var /. Hold[inj_] :> Block[inj, x*y*z] (*24*) ?x (*Global`x --- so we did not leak*)



Top 50 recent answers are included