Change arguments of a product of functions
Clash Royale CLAN TAG#URR8PPP
$begingroup$
I am trying to do the following with rule-based pattern matching
(f1[t] f2[t] f3[t]) /. x__ -> n[
Product[x[[i, 0]][om[i]], i, 3]] // Quiet
which gives me the output n[f1[om[1]] f2[om[2]] f3[om[3]]]
. However, it seems as if one cannot specify parts of a pattern MMA gives the error messages
"Part specification x[[1,0]] is longer than depth of object"
I would like to do the operatoration for a product of n
arbitrary functions f1[t]
...fn[t]
where the number of functions is automatically detected (I cannot use Length
as well). How would one do it correctly?
pattern-matching
$endgroup$
add a comment |
$begingroup$
I am trying to do the following with rule-based pattern matching
(f1[t] f2[t] f3[t]) /. x__ -> n[
Product[x[[i, 0]][om[i]], i, 3]] // Quiet
which gives me the output n[f1[om[1]] f2[om[2]] f3[om[3]]]
. However, it seems as if one cannot specify parts of a pattern MMA gives the error messages
"Part specification x[[1,0]] is longer than depth of object"
I would like to do the operatoration for a product of n
arbitrary functions f1[t]
...fn[t]
where the number of functions is automatically detected (I cannot use Length
as well). How would one do it correctly?
pattern-matching
$endgroup$
add a comment |
$begingroup$
I am trying to do the following with rule-based pattern matching
(f1[t] f2[t] f3[t]) /. x__ -> n[
Product[x[[i, 0]][om[i]], i, 3]] // Quiet
which gives me the output n[f1[om[1]] f2[om[2]] f3[om[3]]]
. However, it seems as if one cannot specify parts of a pattern MMA gives the error messages
"Part specification x[[1,0]] is longer than depth of object"
I would like to do the operatoration for a product of n
arbitrary functions f1[t]
...fn[t]
where the number of functions is automatically detected (I cannot use Length
as well). How would one do it correctly?
pattern-matching
$endgroup$
I am trying to do the following with rule-based pattern matching
(f1[t] f2[t] f3[t]) /. x__ -> n[
Product[x[[i, 0]][om[i]], i, 3]] // Quiet
which gives me the output n[f1[om[1]] f2[om[2]] f3[om[3]]]
. However, it seems as if one cannot specify parts of a pattern MMA gives the error messages
"Part specification x[[1,0]] is longer than depth of object"
I would like to do the operatoration for a product of n
arbitrary functions f1[t]
...fn[t]
where the number of functions is automatically detected (I cannot use Length
as well). How would one do it correctly?
pattern-matching
pattern-matching
asked Jan 17 at 9:45
Display NameDisplay Name
57438
57438
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
f1[t] f2[t] f3[t] /. Times[x_, y__] :> n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Also
Module[i = 1, f1[t] f2[t] f3[t] /. t :> om[i++] // n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Update: "If all the functions are equal":
Inactivate[f1[t] f1[t] f1[t]] /.
Inactive[Times][x_, y__] :> Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, Inactivate[f1[t] f1[t] f1[t]] /. t :> om[i++] // n]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Update 2: "... if one replaces e.g. f1[t] to become (x1[t]-x2[t])"
The first method works if the level specification -2
is used in MapIndexed
:
Inactivate[f1[t] f2[t] f3[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Inactivate[f1[t] f1[t] f1[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])] /.
Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
The second method can also be modified (so that ReplaceAll
is mapped onto the terms of the product) to work for all three cases:
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f2[t] f3[t]]]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f1[t] f1[t]]]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])]]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
$endgroup$
$begingroup$
Thank you for your answer. It works forf1 != f2 != f3
but stops working if all the functions are equal.
$endgroup$
– Display Name
Jan 17 at 11:56
$begingroup$
@DisplayName, please see the update.
$endgroup$
– kglr
Jan 17 at 12:05
$begingroup$
Thanks again. I think I lack a little bit of knowledge to come up with sth like this. I just read into pattern matching but it needs some time to settle. But I also like the approach with theRuleDelayed
. The mathematical background of this question is to write a product in time domain as a product in Fourier space via the convolution theorem.n
is then simply a functional involving integrations over theom
s.
$endgroup$
– Display Name
Jan 17 at 12:18
$begingroup$
I think the code must be edited once more if one replaces e.g.f1[t]
to become(x1[t]-x2[t])
.
$endgroup$
– Display Name
Jan 17 at 14:14
$begingroup$
@DisplayName, please see update 2.
$endgroup$
– kglr
Jan 18 at 10:52
|
show 1 more comment
$begingroup$
A simple function can do it.
changeArg[p : Times[__], var_Symbol, head_Symbol] :=
head[MapIndexed[#1[var[#2[[1]]]] &, Head /@ p]]
changeArg[f1[t] f2[t] f3[t], om, n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
$endgroup$
$begingroup$
Thank you for another possible answer. I think in the current form it doesn't cover the case of equal functions.
$endgroup$
– Display Name
Jan 17 at 12:32
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189658%2fchange-arguments-of-a-product-of-functions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
f1[t] f2[t] f3[t] /. Times[x_, y__] :> n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Also
Module[i = 1, f1[t] f2[t] f3[t] /. t :> om[i++] // n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Update: "If all the functions are equal":
Inactivate[f1[t] f1[t] f1[t]] /.
Inactive[Times][x_, y__] :> Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, Inactivate[f1[t] f1[t] f1[t]] /. t :> om[i++] // n]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Update 2: "... if one replaces e.g. f1[t] to become (x1[t]-x2[t])"
The first method works if the level specification -2
is used in MapIndexed
:
Inactivate[f1[t] f2[t] f3[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Inactivate[f1[t] f1[t] f1[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])] /.
Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
The second method can also be modified (so that ReplaceAll
is mapped onto the terms of the product) to work for all three cases:
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f2[t] f3[t]]]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f1[t] f1[t]]]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])]]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
$endgroup$
$begingroup$
Thank you for your answer. It works forf1 != f2 != f3
but stops working if all the functions are equal.
$endgroup$
– Display Name
Jan 17 at 11:56
$begingroup$
@DisplayName, please see the update.
$endgroup$
– kglr
Jan 17 at 12:05
$begingroup$
Thanks again. I think I lack a little bit of knowledge to come up with sth like this. I just read into pattern matching but it needs some time to settle. But I also like the approach with theRuleDelayed
. The mathematical background of this question is to write a product in time domain as a product in Fourier space via the convolution theorem.n
is then simply a functional involving integrations over theom
s.
$endgroup$
– Display Name
Jan 17 at 12:18
$begingroup$
I think the code must be edited once more if one replaces e.g.f1[t]
to become(x1[t]-x2[t])
.
$endgroup$
– Display Name
Jan 17 at 14:14
$begingroup$
@DisplayName, please see update 2.
$endgroup$
– kglr
Jan 18 at 10:52
|
show 1 more comment
$begingroup$
f1[t] f2[t] f3[t] /. Times[x_, y__] :> n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Also
Module[i = 1, f1[t] f2[t] f3[t] /. t :> om[i++] // n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Update: "If all the functions are equal":
Inactivate[f1[t] f1[t] f1[t]] /.
Inactive[Times][x_, y__] :> Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, Inactivate[f1[t] f1[t] f1[t]] /. t :> om[i++] // n]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Update 2: "... if one replaces e.g. f1[t] to become (x1[t]-x2[t])"
The first method works if the level specification -2
is used in MapIndexed
:
Inactivate[f1[t] f2[t] f3[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Inactivate[f1[t] f1[t] f1[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])] /.
Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
The second method can also be modified (so that ReplaceAll
is mapped onto the terms of the product) to work for all three cases:
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f2[t] f3[t]]]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f1[t] f1[t]]]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])]]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
$endgroup$
$begingroup$
Thank you for your answer. It works forf1 != f2 != f3
but stops working if all the functions are equal.
$endgroup$
– Display Name
Jan 17 at 11:56
$begingroup$
@DisplayName, please see the update.
$endgroup$
– kglr
Jan 17 at 12:05
$begingroup$
Thanks again. I think I lack a little bit of knowledge to come up with sth like this. I just read into pattern matching but it needs some time to settle. But I also like the approach with theRuleDelayed
. The mathematical background of this question is to write a product in time domain as a product in Fourier space via the convolution theorem.n
is then simply a functional involving integrations over theom
s.
$endgroup$
– Display Name
Jan 17 at 12:18
$begingroup$
I think the code must be edited once more if one replaces e.g.f1[t]
to become(x1[t]-x2[t])
.
$endgroup$
– Display Name
Jan 17 at 14:14
$begingroup$
@DisplayName, please see update 2.
$endgroup$
– kglr
Jan 18 at 10:52
|
show 1 more comment
$begingroup$
f1[t] f2[t] f3[t] /. Times[x_, y__] :> n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Also
Module[i = 1, f1[t] f2[t] f3[t] /. t :> om[i++] // n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Update: "If all the functions are equal":
Inactivate[f1[t] f1[t] f1[t]] /.
Inactive[Times][x_, y__] :> Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, Inactivate[f1[t] f1[t] f1[t]] /. t :> om[i++] // n]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Update 2: "... if one replaces e.g. f1[t] to become (x1[t]-x2[t])"
The first method works if the level specification -2
is used in MapIndexed
:
Inactivate[f1[t] f2[t] f3[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Inactivate[f1[t] f1[t] f1[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])] /.
Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
The second method can also be modified (so that ReplaceAll
is mapped onto the terms of the product) to work for all three cases:
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f2[t] f3[t]]]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f1[t] f1[t]]]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])]]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
$endgroup$
f1[t] f2[t] f3[t] /. Times[x_, y__] :> n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Also
Module[i = 1, f1[t] f2[t] f3[t] /. t :> om[i++] // n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Update: "If all the functions are equal":
Inactivate[f1[t] f1[t] f1[t]] /.
Inactive[Times][x_, y__] :> Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, Inactivate[f1[t] f1[t] f1[t]] /. t :> om[i++] // n]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Update 2: "... if one replaces e.g. f1[t] to become (x1[t]-x2[t])"
The first method works if the level specification -2
is used in MapIndexed
:
Inactivate[f1[t] f2[t] f3[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Inactivate[f1[t] f1[t] f1[t]] /. Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])] /.
Inactive[Times][x_, y__] :>
Activate@n[Times @@ MapIndexed[#[[0]][om[#2[[1]]]] &, x, y, -2]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
The second method can also be modified (so that ReplaceAll
is mapped onto the terms of the product) to work for all three cases:
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f2[t] f3[t]]]]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[f1[t] f1[t] f1[t]]]]
n[f1[om[1]] f1[om[2]] f1[om[3]]]
Activate@Module[i = 1, n[With[j = i++, # /. t :> om[j]] & /@
Inactivate[(x1[t] - x2[t]) (x1[t] - x2[t]) (x1[t] - x2[t])]]]
n[(x1[om[1]] - x2[om[1]]) (x1[om[2]] - x2[om[2]]) (x1[om[3]] - x2[om[3]])]
edited Jan 18 at 11:07
answered Jan 17 at 11:43
kglrkglr
181k10200413
181k10200413
$begingroup$
Thank you for your answer. It works forf1 != f2 != f3
but stops working if all the functions are equal.
$endgroup$
– Display Name
Jan 17 at 11:56
$begingroup$
@DisplayName, please see the update.
$endgroup$
– kglr
Jan 17 at 12:05
$begingroup$
Thanks again. I think I lack a little bit of knowledge to come up with sth like this. I just read into pattern matching but it needs some time to settle. But I also like the approach with theRuleDelayed
. The mathematical background of this question is to write a product in time domain as a product in Fourier space via the convolution theorem.n
is then simply a functional involving integrations over theom
s.
$endgroup$
– Display Name
Jan 17 at 12:18
$begingroup$
I think the code must be edited once more if one replaces e.g.f1[t]
to become(x1[t]-x2[t])
.
$endgroup$
– Display Name
Jan 17 at 14:14
$begingroup$
@DisplayName, please see update 2.
$endgroup$
– kglr
Jan 18 at 10:52
|
show 1 more comment
$begingroup$
Thank you for your answer. It works forf1 != f2 != f3
but stops working if all the functions are equal.
$endgroup$
– Display Name
Jan 17 at 11:56
$begingroup$
@DisplayName, please see the update.
$endgroup$
– kglr
Jan 17 at 12:05
$begingroup$
Thanks again. I think I lack a little bit of knowledge to come up with sth like this. I just read into pattern matching but it needs some time to settle. But I also like the approach with theRuleDelayed
. The mathematical background of this question is to write a product in time domain as a product in Fourier space via the convolution theorem.n
is then simply a functional involving integrations over theom
s.
$endgroup$
– Display Name
Jan 17 at 12:18
$begingroup$
I think the code must be edited once more if one replaces e.g.f1[t]
to become(x1[t]-x2[t])
.
$endgroup$
– Display Name
Jan 17 at 14:14
$begingroup$
@DisplayName, please see update 2.
$endgroup$
– kglr
Jan 18 at 10:52
$begingroup$
Thank you for your answer. It works for
f1 != f2 != f3
but stops working if all the functions are equal.$endgroup$
– Display Name
Jan 17 at 11:56
$begingroup$
Thank you for your answer. It works for
f1 != f2 != f3
but stops working if all the functions are equal.$endgroup$
– Display Name
Jan 17 at 11:56
$begingroup$
@DisplayName, please see the update.
$endgroup$
– kglr
Jan 17 at 12:05
$begingroup$
@DisplayName, please see the update.
$endgroup$
– kglr
Jan 17 at 12:05
$begingroup$
Thanks again. I think I lack a little bit of knowledge to come up with sth like this. I just read into pattern matching but it needs some time to settle. But I also like the approach with the
RuleDelayed
. The mathematical background of this question is to write a product in time domain as a product in Fourier space via the convolution theorem. n
is then simply a functional involving integrations over the om
s.$endgroup$
– Display Name
Jan 17 at 12:18
$begingroup$
Thanks again. I think I lack a little bit of knowledge to come up with sth like this. I just read into pattern matching but it needs some time to settle. But I also like the approach with the
RuleDelayed
. The mathematical background of this question is to write a product in time domain as a product in Fourier space via the convolution theorem. n
is then simply a functional involving integrations over the om
s.$endgroup$
– Display Name
Jan 17 at 12:18
$begingroup$
I think the code must be edited once more if one replaces e.g.
f1[t]
to become (x1[t]-x2[t])
.$endgroup$
– Display Name
Jan 17 at 14:14
$begingroup$
I think the code must be edited once more if one replaces e.g.
f1[t]
to become (x1[t]-x2[t])
.$endgroup$
– Display Name
Jan 17 at 14:14
$begingroup$
@DisplayName, please see update 2.
$endgroup$
– kglr
Jan 18 at 10:52
$begingroup$
@DisplayName, please see update 2.
$endgroup$
– kglr
Jan 18 at 10:52
|
show 1 more comment
$begingroup$
A simple function can do it.
changeArg[p : Times[__], var_Symbol, head_Symbol] :=
head[MapIndexed[#1[var[#2[[1]]]] &, Head /@ p]]
changeArg[f1[t] f2[t] f3[t], om, n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
$endgroup$
$begingroup$
Thank you for another possible answer. I think in the current form it doesn't cover the case of equal functions.
$endgroup$
– Display Name
Jan 17 at 12:32
add a comment |
$begingroup$
A simple function can do it.
changeArg[p : Times[__], var_Symbol, head_Symbol] :=
head[MapIndexed[#1[var[#2[[1]]]] &, Head /@ p]]
changeArg[f1[t] f2[t] f3[t], om, n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
$endgroup$
$begingroup$
Thank you for another possible answer. I think in the current form it doesn't cover the case of equal functions.
$endgroup$
– Display Name
Jan 17 at 12:32
add a comment |
$begingroup$
A simple function can do it.
changeArg[p : Times[__], var_Symbol, head_Symbol] :=
head[MapIndexed[#1[var[#2[[1]]]] &, Head /@ p]]
changeArg[f1[t] f2[t] f3[t], om, n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
$endgroup$
A simple function can do it.
changeArg[p : Times[__], var_Symbol, head_Symbol] :=
head[MapIndexed[#1[var[#2[[1]]]] &, Head /@ p]]
changeArg[f1[t] f2[t] f3[t], om, n]
n[f1[om[1]] f2[om[2]] f3[om[3]]]
answered Jan 17 at 12:17
m_goldbergm_goldberg
85.6k872196
85.6k872196
$begingroup$
Thank you for another possible answer. I think in the current form it doesn't cover the case of equal functions.
$endgroup$
– Display Name
Jan 17 at 12:32
add a comment |
$begingroup$
Thank you for another possible answer. I think in the current form it doesn't cover the case of equal functions.
$endgroup$
– Display Name
Jan 17 at 12:32
$begingroup$
Thank you for another possible answer. I think in the current form it doesn't cover the case of equal functions.
$endgroup$
– Display Name
Jan 17 at 12:32
$begingroup$
Thank you for another possible answer. I think in the current form it doesn't cover the case of equal functions.
$endgroup$
– Display Name
Jan 17 at 12:32
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189658%2fchange-arguments-of-a-product-of-functions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown