Message Boards Message Boards

GROUPS:

Understand the meaning of & operator?

Posted 14 days ago
189 Views
|
2 Replies
|
3 Total Likes
|

Hi there,

A simple problem appeared and I can't solve it by myself. Plese don't focus on the meaning of the functions and of the values assigned to variables: I suspect the problem is on how I treat aa and bb.

After defining the following functions XX and Hvv that I can call in the code:

XX = -Inverse[aa].(bb.UU );

Hvv = cc.(Inverse[s i - aa].bb);

If I call

X=XX&[aa=4,bb=5,cc=6]

and then call Hvv

Hv=Hvv&[aa=6,bb=7]

I get wrong values for Hv.

But if after calling X=XX&(ecc.) I re-evaluate the definition of Hvv = cc.(Inverse[s i - aa].bb) then everything is fine if I call now Hv=Hvv(ecc.).

I guess I'm misunderstanding the meaning of f(aa)&(aa=a) which I intend as "evaluate f ifor aa=a".

You guys have insight on how to solve this? Thanks.

2 Replies
Posted 14 days ago

Are you able to provide a minimal example with code one could actually evaluate?

I think there are some fundamental issues in your syntax. For example to define a function XX with 3 arguments you would want to instead do

XX[aa_, bb_, UU_] := -Inverse[aa].(bb.UU )

or something similar. The following doesn't really make a ton of sense:

XX = -Inverse[aa].(bb.UU );
X=XX&[aa=4,bb=5,cc=6]

Consider this documentation page: https://reference.wolfram.com/language/tutorial/DefiningFunctions.html

Thanks a lot. I'm learning Mathematica bit by bit so I do not have the general picture. Now I know how to define and call proper functions and the code works fine.

What I did until know (and worked until now) was declaring variables (dependent "functions") which depended on other variables (independent variables) and then evaluate the dependent ones using & operator on the independent.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract