Really Introductory Mathematica Question

Click For Summary
SUMMARY

This discussion addresses a common issue in Mathematica regarding variable assignment and plotting. The user initially attempts to define a function using the syntax r[_t], which results in an empty plot when used in ParametricPlot3D. The correct approach involves using r[t_]:={E^(-t/10) Cos[t], E^(-t/10) Sin[t], E^(-t/10)} with := for delayed evaluation, allowing proper plotting of the defined function. The terms RHS and LHS are clarified as standard mathematical abbreviations for Right Hand Side and Left Hand Side, respectively.

PREREQUISITES
  • Understanding of Mathematica syntax and functions
  • Familiarity with parametric plotting in Mathematica
  • Knowledge of delayed assignment using := in Mathematica
  • Basic mathematical concepts of Right Hand Side (RHS) and Left Hand Side (LHS)
NEXT STEPS
  • Explore advanced plotting techniques in Mathematica
  • Learn about function definitions and scoping in Mathematica
  • Investigate the use of patterns in function definitions with _ and _t
  • Study the differences between = and := in Mathematica
USEFUL FOR

Mathematica users, students learning computational mathematics, and anyone interested in mastering function plotting and variable assignment in Mathematica.

dpeagler
Messages
32
Reaction score
0
Hello everyone, I apologize for posting such an introductory mathematica question, but I can't find an answer anywhere.

I seem to be having trouble assigning variables and then plotting with the variable name. Perhaps I'm thinking too much in terms of ordinary computer programming or something. Here is a list of my code.

In: r[_t] = {E^(-t/10) Cos[t], E^(-t/10) Sin[t], E^(-t/10)}
Out: {E^(-t/10) Cos[t], E^(-t/10) Sin[t], E^(-t/10)}
In: ParametricPlot3D[{r[_t]}, {t, 0, 40}]

I'm not going to post the out for the last part, because all it did was graph an empty 3D form. I can get it to graph properly if I just type the functions into the ParametricPlot command, but there has to be a better way. I even tried breaking it up into x, y, and z separate variables. Any help is greatly appreciated.
 
Physics news on Phys.org
Hi there,

Try:
Code:
r[t_]:={E^(-t/10) Cos[t],E^(-t/10) Sin[t],E^(-t/10)}
Code:
ParametricPlot3D[r[t], {t,0,40}]

The expression t_ means a pattern named t that matches anything. So when you later use r[t] it will fetch the RHS of the definition. I used := instead of = since that is a DelayedSet as opposed to Set - thus it doesn't evaluate the RHS until it is called - which is more often what you want.
 
Thanks that worked a lot better.

Just curious about some of the terms you used. Particularly RHS?

Thanks again.
 
Sorry about that, I thought that RHS and LHS were pretty standard abbreviations in maths for Right and Left Hand Side respectively
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K