Tag Info

New answers tagged

1

Conjugate by default assumes that all symbolic quantities are potentially complex. This may seem annoying at first, but there is a very good reason for it, and one way to see why is to define your own version of Conjugate, and see it fail. For educational purposes, I do that below. Define $Conjugate as follows: $Conjugate[x_] := x /. Complex[a_, b_] :> ...


0

ClearAll[g, x, y, diff]; g = 5*x - 5*x*y - 5*y; Maybe: D[g /. x -> (diff + y), diff] (* 5 - 5 y *) or D[g /. y -> (x - diff), diff] (* 5 + 5 x *)


3

Here is a method that is not exactly to your specification but which may serve you anyway. It uses a Symbol argument. Because a Symbol is passed it is automatically modified by Module and does not need the guesswork of $ModuleNumber etc. but it does need string conversion and cleanup. SetAttributes[printVal, HoldFirst]; printVal[s_Symbol] := Print @ ...


1

The following gets the first two steps: m = {{1, 2}, {0, 2}, {3, 2}, {0, 2}, {0, 2}, {0, 2}, {4, 2}}; v = 1 - Unitize[m[[All, 1]]] (*{0,1,0,1,1,1,0} *) vv = Flatten@(Accumulate /@ Split@v) (* {0,1,0,1,2,3,0} *) Update: ... the last step ClearAll[ff]; ff[0] = 1; ff[n_] := Piecewise[{{ff[n-1] m[[n, 2]], vv[[n]] > 1}, {m[[n, 2]], vv[[n]] == 1}}, m[[n, ...



Top 50 recent answers are included