Mathematica: plot and evaluate function of 2 variables

Click For Summary

Discussion Overview

The discussion revolves around evaluating and plotting a function of two variables in Mathematica, specifically in the context of spherical coordinates. Participants are sharing their approaches and troubleshooting techniques related to the use of SphericalPlot3D and Manipulate functions.

Discussion Character

  • Technical explanation
  • Exploratory
  • Homework-related

Main Points Raised

  • One participant presents a function R(t, θ) involving spherical harmonics and seeks assistance with plotting it in Mathematica.
  • Another participant provides a code snippet that defines functions a(t) and b(t), and demonstrates how to use SphericalPlot3D and Manipulate to plot R.
  • A later reply suggests breaking down the problem into simpler tasks to identify potential issues, recommending to first confirm the output of a basic spherical harmonic plot.
  • There is a mention of substituting different values in the spherical harmonic function to test its behavior.
  • Participants express uncertainty about missing details in their implementations and seek clarification on specific aspects of their code.

Areas of Agreement / Disagreement

Participants generally agree on the approach to use SphericalPlot3D and Manipulate, but there is no consensus on the specific implementation details or whether the proposed solutions will resolve the original poster's issues.

Contextual Notes

Some limitations include potential missing assumptions in the original function definitions and the need for clarity on the expected behavior of the plots. The discussion does not resolve whether the provided code snippets will function as intended.

hasidim
Messages
15
Reaction score
0
Hi all,

I am trying to evaluate and plot a function of two variable in mathematica.

Function:

Code:
R(t,\theta) = a(t) + b(t)*Y_n(\theta)

Where a(t) and b(t) are functions (that I have evaluated already), and Y is the spherical harmonic for a given n, and R is the radius.

In mathematica I am unsure how to evaluate and plot a function of two variables in spherical coordinates. I attempted to use "SphericalPlot3D" to plot R as a function of \theta and \phi, and "Manipulate" to add a slider to adjust the time but am having no luck.

Any help would be APPRECIATED!
 
Physics news on Phys.org
Is this something like what you are trying to do?

a[t_] := 2t; b[t_] := t^2; m = 1;(* < --- Substitute your functions here *)
R[t_, n_, m_, theta_, phi_] := a[t] + b[t]*SphericalHarmonicY[n, m, theta, phi]
Manipulate[SphericalPlot3D[R[t, n, m, theta, phi], {theta, 0, 2Pi}, {phi, 0, Pi}], {t, 0, 1}, {n, 0, 4, 1}]

Can you perhaps adapt this for what you need?
 
Bill Simpson said:
Is this something like what you are trying to do?

a[t_] := 2t; b[t_] := t^2; m = 1;(* < --- Substitute your functions here *)
R[t_, n_, m_, theta_, phi_] := a[t] + b[t]*SphericalHarmonicY[n, m, theta, phi]
Manipulate[SphericalPlot3D[R[t, n, m, theta, phi], {theta, 0, 2Pi}, {phi, 0, Pi}], {t, 0, 1}, {n, 0, 4, 1}]

Can you perhaps adapt this for what you need?

That is pretty similar to what I have tried... but, I'll try copying that and modifying it.

As usual, I suspect that I am missing just one small detail.
 
If your modification doesn't work then divide the problem into simpler tasks.
Confirm that
SphericalPlot3D[SphericalHarmonicY[1, 2, theta, phi]], {theta, 0, 2Pi}, {phi, 0, Pi}]
plot matches http://mathworld.wolfram.com/SphericalHarmonic.html
and substitute a few other values for the 1 and 2.
Then try a simpler Manipulate example using a Real and Integer value from the Help and confirm that works. That might uncover some of your missing details.
 

Similar threads

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