Tag Info

Hot answers tagged

17

One way is to use an extra argument that acts as a switch. Clear[f]; f[0] = 1; f[1] = 1; f[n_, True] := f[n - 1] + f[n - 2] Example: f7 = f[7, True] (* Out[329]= f[5] + f[6] *) To proceed another step, can do a replacement. f7 /. f[aa_] :> f[aa, True] (* Out[330]= f[3] + 2 f[4] + f[5] *) Can use Nest to repeat this n times. Nest[# /. f[aa_] ...


7

Here is a trick that allows you to get exactly what you're looking for: FourierTransform[ InverseFourierTransform[ x/y DiracDelta[x - y], x, k], k, x] DiracDelta[x - y] What I did here is to apply the Fourier transform and its inverse, which is of course the identity and therefore is equivalent to the original expression. But in doing so, ...


7

If we are willing to confine ourselves to functions like the example f which: is defined using DownValues only, and has no special attributes such as HoldAll, etc. ... then the following lifting function might be useful: ClearAll[stepper] SetAttributes[stepper, HoldAll] stepper[f_Symbol] := Module[{rules, g} , rules = Rule @@@ ...


4

The answers are great. I wanted to add that the problem you are trying to solve fits way better with replacement rules than function definitions, so switching to those can provide a more understandable answer Clear[f]; frules = {f[0 | 1] :> 1, f[n_] :> f[n - 1] + f[n - 2]}; f[7] /. frules (* same as f[7]//ReplaceAll[frules] *) f[7] /. frules /. ...


3

If you're using M10, you could do it with Inactivate (which formats more nicely in Mathematica than it does here in plain text.) Inactivate[f[7] /. #, f] &[DownValues[f]] (* Inactive[f][5] + Inactive[f][6] *) Then Nest it: Clear[step]; SetAttributes[step, HoldFirst]; step[e_] := step[e, 1] step[e_, n_] := Inactivate[Nest[Function[{x}, x /. #], e, n], ...


1

DiracDelta must be inside an integral to have much meaning. From its documentation: "DiracDelta can be used in integrals, integral transforms, and differential equations. " Assuming[Element[y, Reals], Integrate[x/y DiracDelta[x - y], {x, -Infinity, Infinity}]] 1 Assuming[Element[x, Reals], Integrate[x/y DiracDelta[x - y], {y, -Infinity, Infinity}]] ...


1

In Mathematica 10 using << Notation` Notation[x' => xPrime] seems to work to "disconnect" x' from its meaning as a derivative. (Note- the Notation text used here represents entering using the Notation Palette. Mathematica interprets this to Notation[ParsedBoxWrapper[ RowBox[{"x", "'"}]] \[DoubleLongRightArrow] ParsedBoxWrapper["xPrime"] ] ...


1

h[f[0]] := f[0]; h[f[1]] := f[1]; h[f[x_]] := f[x - 1] + f[x - 2]; nst[n_, num_] := Total@Nest[Cases[#, f[y_] :> h[f[y]], Infinity] &,{f[n]}, num] Testing: Table[nst[10, j], {j, 0, 9}] // TableForm



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