Given list \(a = \{1,2,3,4\}\) and list \(b=\{5,6,7,8\}\) how to to call function \(f(x,y)\) by taking \(\sin (x),\cos (y)\) from \(a,b\) one a time so that the result gives \[ f(\sin (1),\cos (5)),f(\sin (2),\cos (6)),f(\sin (3),\cos (7)),f(\sin (4),\cos (8)) \]
Mathematica
Remove["Global`*"] a = {1, 2, 3, 4}; b = {5, 6, 7, 8}; MapThread[f[Sin[#1],Cos[#2]] &, {a, b}]
{f[Sin[1], Cos[5]], f[Sin[2], Cos[6]], f[Sin[3], Cos[7]], f[Sin[4], Cos[8]]}
Maple
restart; a:=[1,2,3,4]; b:=[5,6,7,8]; f~(sin~(a),cos~(b))
[f(sin(1), cos(5)), f(sin(2), cos(6)), f(sin(3), cos(7)), f(sin(4), cos(8))]
Given list \(a = \{1,2,3,4\}\) and list \(b=\{5,6,7,8\}\) how to to call function \(f(2 x+x^2+\sin (x),2+\cos (y))\) by taking \(x,y\) from \(a,b\) one a time so that the result gives \[ \{f(3+\sin (1),5+\cos (5)),f(8+\sin (2),6+\cos (6)),f(15+\sin (3),7+\cos (7)),f(24+\sin (4),8+\cos (8))\} \]
Mathematica
Remove["Global`*"] a = {1, 2, 3, 4}; b = {5, 6, 7, 8}; MapThread[f[2*#1 + #1^2 + Sin[#1], #2 + Cos[#2]] &, {a, b}]
{f[3+Sin[1],5+Cos[5]],f[8+Sin[2],6+Cos[6]],f[15+Sin[3],7+Cos[7]],f[24+Sin[4],8+Cos[8]]}
Maple
In Maple, since it does not have slot numbers #
to use, it is better to make a function on the
fly, which does the exact same thing.
restart; a:=[1,2,3,4]; b:=[5,6,7,8]; f~( (x->2*x+x^2+sin(x))~(a), (x->2+cos(x)) ~(b))
[f(3 + sin(1), 2 + cos(5)), f(8 + sin(2), 2 + cos(6)), f(15 + sin(3), 2 + cos(7)), f(24 + sin(4), 2 + cos(8))]