# How to plot a function with several constants using Wolfram Mathematica

• Hany_Draidi
In summary, you can substitute any constants for a, m, and h to find the wave function for the problem. Then, you can plot it using Mathematica.
Hany_Draidi
How can I plot this probability density function using Wolfram Mathematica Keeping the constants the same.
ψ*ψ= A^2 (x^2)exp(-2a(mx^2/h)) ; where m,a,A,and h are constants and I want the graph in terms of them.
I tried: Plot[A^2 *(x^2)*exp(-2a(mx^2/h)),{x,-1000,1000}]

You can't.

Hany_Draidi said:
How can I plot this probability density function using Wolfram Mathematica Keeping the constants the same.

ψ*ψ= A^2 (x^2)exp(-2a(mx^2/h)) ; where m,a,A,and h are constants and I want the graph in terms of them.

I tried: Plot[A^2 *(x^2)*exp(-2a(mx^2/h)),{x,-1000,1000}]

I would say you can't do that since Wolfram Alpha assumes that these terms are variables. Hence, there is no approach for this. You could just substitute the constants with any values and then, check the graph. You just have a graph; that doesn't guaranteed the exact graph you should expect. You will need to substitute random values!

I may be wrong. I am just assuming that is true.

You should be able to solve for A in terms of a, m, and h by requiring the wave function be normalized. That'll get rid of one constant.

What you want to do is come up with some combination of the constants that is a characteristic length in the problem. In this case, your wave function is
$$\psi(x) = A x e^{-\frac{ma}{\hbar}x^2}.$$ The argument of the exponential has to be unitless, and if you check the units, you'll indeed find that the combination ##ma/\hbar## has units of 1/length2. A natural choice for your length scale would therefore be ##\alpha=\sqrt{\hbar/ma}##. Now if you change variables from ##x## to ##x/\alpha##, you'll find that all of the constants will be gone. Once you have the density in that form, you can plot it using Mathematica.

Try using Manipulate. You can set the constants to starting values and then vary them with the sliders to see what effect they have. A notebook is attached

#### Attachments

• Manipulate.nb
5.5 KB · Views: 842

## 1. How do I define multiple constants in a function using Wolfram Mathematica?

To define multiple constants in a function, you can use the "With" command in Wolfram Mathematica. For example, if you want to plot the function f(x) = ax^2 + bx + c, you can define the constants a, b, and c using the syntax "With[{a = 1, b = 2, c = 3}, f[x_] := ax^2 + bx + c]". This will create a function f with the specified constants and can be used for plotting.

## 2. What is the syntax for plotting a function with multiple constants in Wolfram Mathematica?

To plot a function with multiple constants in Wolfram Mathematica, you can use the "Plot" command. The syntax for plotting a function f(x) with variable x and constants a, b, and c is "Plot[f[x] /. {a -> aVal, b -> bVal, c -> cVal}, {x, xmin, xmax}]", where aVal, bVal, and cVal are the values of the constants and xmin and xmax are the desired range for x.

## 3. Can I change the values of the constants while plotting the function in Wolfram Mathematica?

Yes, you can change the values of the constants while plotting the function in Wolfram Mathematica. You can use the "Manipulate" command to create a dynamic plot where you can manipulate the values of the constants and see the changes in the plotted function. The syntax for this is "Manipulate[Plot[f[x] /. {a -> aVal, b -> bVal, c -> cVal}, {x, xmin, xmax}], {aVal, aMin, aMax}, {bVal, bMin, bMax}, {cVal, cMin, cMax}]", where aMin, aMax, bMin, bMax, cMin, and cMax are the minimum and maximum values for the constants.

## 4. How can I add a legend to the plot of a function with multiple constants in Wolfram Mathematica?

To add a legend to the plot of a function with multiple constants in Wolfram Mathematica, you can use the "PlotLegends" option in the "Plot" command. The syntax for this is "Plot[f[x] /. {a -> aVal, b -> bVal, c -> cVal}, {x, xmin, xmax}, PlotLegends -> {a, b, c}]", where a, b, and c are the names of the constants that will be displayed in the legend.

## 5. Is there any other way to plot a function with multiple constants in Wolfram Mathematica?

Yes, besides using the "Plot" command, you can also use the "ParametricPlot" command to plot a function with multiple constants. The syntax for this is "ParametricPlot[{f[x] /. {a -> aVal, b -> bVal, c -> cVal}, x}, {x, xmin, xmax}]", where aVal, bVal, and cVal are the values of the constants and xmin and xmax are the desired range for x. This will create a parametric plot where the x-axis is the function values and the y-axis is the variable x.

• General Discussion
Replies
2
Views
440
• High Energy, Nuclear, Particle Physics
Replies
4
Views
600
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
316
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
788
• Programming and Computer Science
Replies
2
Views
1K
• Calculus and Beyond Homework Help
Replies
8
Views
2K
• Programming and Computer Science
Replies
1
Views
1K
• General Math
Replies
3
Views
307
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K