2
$\begingroup$

This is my very first day using Mathematica, so please forgive me my complete ignorance...

I fear that this might be one of those questions that gets rejected for being "easily found in the documentation"... Nevertheless, searching hard and long through the documentation all that I may, I completely fail to find an answer to my - no doubt obvious - mistake...

I tried to define a function x[t_] and a function y[t_], both as it seems successfully...

I then tried to put them together in a complex valued function f[t_], which I believed to be an operation that could not possibly go wrong...

However to my surprise I keep getting a "Recursion depth of 1024 exceeded during evaluation of f[0]" error...

I really fail to see where this "recursion" could possibly come from...

Could anyone please put this noobie on the right track?

a = 2
(* 2 *)

T = 2^(3/2)
(* 2 Sqrt[2] *)

x[t_] = a Cos[2 Pi t/T] - Cos[2 Pi t]
(* -Cos[2 π t] + 2 Cos[(π t)/Sqrt[2]] *)

y[t_] = a Sin[2 Pi t/T] - Sin[2 Pi t]
(* -Sin[2 π t] + 2 Sin[(π t)/Sqrt[2]] *)

f[t_] = x[t] + I y[t]

During evaluation of In[112]:= $RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of f[0]. >>
During evaluation of In[112]:= Set::write: Tag Hold in Hold[f[0]] is Protected. >>

(* -Cos[2 π t] + 2 Cos[(π t)/Sqrt[2]] + 
    I (-Sin[2 π t] + 2 Sin[(π t)/Sqrt[2]]) *)

f[0]

During evaluation of In[113]:= $RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of f[0]. >>

(* Hold[f[0]] *)
$\endgroup$

closed as off-topic by ciao, Dr. belisarius, bbgodfrey, Kuba, Karsten 7. Apr 2 '15 at 9:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – ciao, Dr. belisarius, bbgodfrey, Karsten 7.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Apr 2 '15 at 0:16
  • 1
    $\begingroup$ I think you want to do your assignments with f[t_] := (note the extra colon, "delayed assignment"). I don't see the recursion here either, but if you have done a bunch of trial-and-errors, then you may have some definitions left over that cause the recurrence. Simply quit the kernel (or mathematica) and start again. $\endgroup$ – Eric Brown Apr 2 '15 at 0:17
3
$\begingroup$

So much wrong there...

a = 2;
tx = 2^(3/2);
x[t_] := a Cos[2 Pi t/tx] - Cos[2 Pi t];
y[t_] := a Sin[2 Pi t/tx] - Sin[2 Pi t];
f[t_] := x[t] + I y[t];

f[20]

(* -1 + 2 Cos[10 Sqrt[2] π] + 2 I Sin[10 Sqrt[2] π] *)

Don't use uppercase initials for your symbols - you might clash with built-ins.

Don't use some external user-defined global symbol inside a definition in the manner you have unless there's a good reason to do so (I left that as is, but it's bad practice).

Read the documentation, learn the difference between Set (=) and SetDelayed (:=).

Read What are the most common pitfalls awaiting new users? on this very site. Great resource for new users.

Go through the tutorials in the Mathematica documentation. Very worthwhile.

$\endgroup$
  • $\begingroup$ Thanks, that fixed it. And thanks for the tips! $\endgroup$ – tasso Apr 2 '15 at 19:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.