Mathematica Mathematica: Plot using abstract variables instead of set values

AI Thread Summary
To create plots in Mathematica that express functions in terms of variables rather than specific values, one effective method is to rescale the x-axis. For instance, to plot a function like sin(a*x) without assigning a specific value to 'a', you can plot sin(x) and label the x-axis in terms of x/a. This allows for a clear representation of the function's behavior across multiples of 'a'. A sample code snippet provided is: Plot[Sin[x], {x, -4, 4}, AxesLabel -> {x/a, y == Sin[a x]}, Ticks -> {{-Pi, -Pi/2, 0, Pi/2, Pi}, {-1, 0, 1}}]. This approach helps in visualizing the function with clean fractions on the plot.
rynlee
Messages
44
Reaction score
0
Hi All,

Does anyone know of a way to make plots in mathematica in terms of variables?

For example, suppose you had a function sin(a*x), and you wanted to plot it but did not want to set a to a specific value, the purpose being to have the graph report multiples of a, not specific numbers.

Usually I just throw in reasonable dummy values for whatever function, but it would be nice to be able to show nice clean fractions on a plot.

Thanks for any ideas!
 
Physics news on Phys.org
You just have to rescale the x-axis. So plot Sin[x], but label the plot sin(a x) and the x-axis in units of x/a.

Try
Code:
Plot[Sin[x], {x, -4, 4}, AxesLabel -> {x/a, y == Sin[a x]}, 
                         Ticks -> {{-Pi, -Pi/2, 0, Pi/2, Pi}, {-1, 0, 1}}]
See the attached image.
 

Attachments

  • Sin(a x).png
    Sin(a x).png
    3.1 KB · Views: 719

Similar threads

Replies
5
Views
2K
Replies
1
Views
7K
Replies
1
Views
3K
Replies
2
Views
3K
Replies
1
Views
4K
Back
Top