Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.7K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Substituting a function inside other one?

Posted 3 years ago

So, I have this function:

f[z_] = Exp[-z] Sin {2  Pi [0.61 z - 0.22z^2 +2 g[z_]}; 

and this function

g[z_]=Cos[2 Pi (1.5 z  - z^2 )]; 

How do I write one inside the other with all the parentheses, braces and square brackets in the right place to be able to write an algorithm? I started testing Mathematica now and I've been trying for days to understand what I've been doing wrong, because the answer doesn't return the sine and cosine by mistake in the square brackets, parentheses...

POSTED BY: Alison Franck
5 Replies

2Pi is multiplied by 1.5 z - z^2, and this is indicated by either explicitly by 2 Pi*(1.5 z - z^2) or implicitly by juxtaposition 2 Pi(1.5 z - z^2). The result is the argument of Cos, and goes within square brackets: Cos[2 Pi (1.5 z - z^2)]. Altogether

f[z_] := 
 Exp[-z] Sin[2 Pi (0.61 z - 0.22 z^2 + 2 Cos[2 Pi (1.5 z - z^2)])]
POSTED BY: Gianluca Gorni
Posted 3 years ago

Ok... How would I write all in one function?

f[z_] := Exp[-z] Sin [2 Pi (0.61 z - 0.22 z^2 + 2 (Cos 2 Pi [1.5 z - z^2]))]

?

I would really appreciate if you could write this down, once I know how to do it I won't go wrong again... You would help a lost student! I'm reading what you're writing, but I have a lot of information for a function and I don't know how to manage it! All the parentheses and square brackets with the pi, the sine and the cosine are making fun of me! :(

POSTED BY: Alison Franck

Check again your syntax. The argument of functions like Sin and Cos goes inside square brackets. Pi is not a function, it is a numerical constant, it is not followed by [].

POSTED BY: Gianluca Gorni
Posted 3 years ago

So, I already tried, and this happens... Do you know what is happening? enter image description here

POSTED BY: Alison Franck

The underscore z_ indicates a pattern, and belongs to the left-hand side. Square brackets are for the argument of functions, curly braces for lists, round parentheses to indicate the order of operations. It is VERY coherent and worth internalizing the distinction, which is lost to traditional math notation:

g[z_] := Cos[2 Pi (1.5 z - z^2)];
f[z_] := Exp[-z] Sin[2 Pi (0.61 z - 0.22 z^2 + 2 g[z])];
Plot[f[z], {z, 0, 2}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard