4
$\begingroup$

Following an old post, I have tried to make a function that calculates the Jackson integral of $q$-calculus:

Clear[JacksonIntegral]; 
JacksonIntegral[f_[x_], q_, b_] := (1 - q) b Sum[q^j f[q^j b], {j, 0, ∞}]

When applied to

A[x_] := x^.25

I have no complaint but no evaluation. More generally, how could I make a new rule in Mathematica?

$\endgroup$
  • $\begingroup$ I'm positive this one is a duplicate now. Possible duplicate. $\endgroup$ – march Mar 19 '16 at 23:03
  • 1
    $\begingroup$ I removed the first sentence, only because this is certainly not a dumb question. $\endgroup$ – J. M.'s discontentment Mar 20 '16 at 9:10
6
$\begingroup$

Your code should work with a small tweak. You just need to use the name of the function instead and input the name of the function or a pure function:

jacksonIntegral[f_, q_, b_] := (1 - q) b Sum[q^j f[q^j b], {j, 0, ∞}]
a[x_] := x^.25
jacksonIntegral[a, 1/2, 0.1]
(* 0.0485152 *)
jacksonIntegral[#^0.25 &, 1/2, 0.1]
(* 0.0485152 *)

Alternatively,

Clear[jacksonIntegral]
SetAttributes[jacksonIntegral, HoldFirst];
jacksonIntegral[f_[x_], q_, b_] := (1 - q) b Sum[q^j f[x] /. x -> q^j b, {j, 0, \[Infinity]}]
a[x_] := x^.25
jacksonIntegral[a[x], 1/2, 0.1]
(* 0.0485152 *)
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.