I need a function fSum that computes the angular sum for some expression, like this:
fSum[3 Sin[2 x], 0, 2 π]
Or from a predefined function, like this:
f[x] = 2 Sin[3 x];
fSum[f, 0, 2 π]
Or plots it like this (exact syntax will probably have to be different here):
Plot[fSum[a Sin[x]], {a, 0, 1}]
I have this stub for fSum:
fSum[expr_, from_ ?NumericQ, to_ ?NumericQ] := Module[{f},
f = ???? (* How to do this? *)
Return[NIntegrate[Abs[D[ArcTan[f'[x]], x]], {x, from, to}]];
]];
I have asked about something similar before and have then received some helpful answers that solved the particular problem at the time. But now I need to make the fSum
function more general so that I also can plot fSum
relative to some plot variables in the expression (or function) passed to it. The only thing I can get to work at ????
in the stub is a hardcoded expression, which is very far from what I need. I have searched this forum and have tried many different solutions, but can not make them work in this case. It would be great if the expr parameter can be both an expression, function, and a string containing the inputform text for the expression.
Table
,Sum
,Integrate
, etc. The syntax you're expecting is possible, but personally I don't quite recommend it. See e.g. mathematica.stackexchange.com/a/297243/1871 mathematica.stackexchange.com/a/127580/1871 $\endgroup$