0
$\begingroup$

I want to be able to write a Function (Operator), that gets 2 arguments. The first argument specifies the kind of "operation", the second the function on which to apply the operation. It should work with $\mathbb{R}\longrightarrow\mathbb{R}^n$ functions.

I have defined a function

myF[t_]:= {Sin[t],Cos[t]}

so a function that maps $\mathbb{R}\longrightarrow\mathbb{R}^n,$ for the case $n=2$.

Now I want to define another function, that evaluates myF at 0, whenever I pass evaluate as (first) argument.

I tried the following

myOperator[evaluate,Fun_[t_]]:=Map[t=0][Fun]

However, the output is

myOperator[evaluate,{0,1}]

So the evaluation happens, but the result is not just the vector... Can anyone help me?

Edit: Of course, I have also tried

myOperator[evaluate,Fun_[t_]]:=Fun[0]

$\endgroup$
2
  • $\begingroup$ You've got a number of syntax issues, but my guess based on your description is that you want myOperator[evaluate_, fun_]: fun[0]. Read the docs so you can understand how Mathematica functions are actually defined $\endgroup$
    – b3m2a1
    Dec 30 '20 at 17:32
  • $\begingroup$ Thank you, this works. But in general, how would I access the variable t? Like myOperator[foo,...]= Integrate[fun,{t,0,3}] $\endgroup$
    – NG98
    Dec 30 '20 at 18:32
0
$\begingroup$

The following should work:

ClearAll[myOperator];
myF[t_] = {Sin[t], Cos[t]}
myOperator[evaluate, f_] = f[0];
myOperator[evaluate, myF]

The output is:

{0, 1}
$\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.