Really Introductory Mathematica Question

Click For Summary

Discussion Overview

The discussion revolves around a Mathematica programming question related to variable assignment and plotting. Participants explore how to properly define a function for use in a 3D parametric plot.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant expresses difficulty in assigning variables and plotting in Mathematica, indicating confusion stemming from conventional programming practices.
  • Another participant suggests using a delayed assignment (:=) for defining the function, explaining that this allows the right-hand side (RHS) to be evaluated only when called.
  • A follow-up question arises regarding the terminology used, specifically the abbreviation RHS.
  • A clarification is provided about the terms RHS and LHS, which are noted as standard abbreviations in mathematics.

Areas of Agreement / Disagreement

Participants appear to agree on the solution provided for the Mathematica question, but there is no indication of broader consensus on the use of terminology.

Contextual Notes

None.

Who May Find This Useful

Individuals learning Mathematica, particularly those new to programming concepts and variable assignments in mathematical software.

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
3K
  • · 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
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K