Plotting a potential function in MATLAB

Click For Summary

Discussion Overview

The discussion revolves around plotting a specific potential function in MATLAB, specifically the function \(\mathcal{V}(\phi_{1}, \phi_{2}) = m^2(\phi_{1}^2 + \phi_{2}^2) + \lambda( \phi_{1}^2 + \phi_{2}^2)^2\). The context includes elements of quantum field theory (QFT) and the demonstration of spontaneous U(1) symmetry breaking. Participants share their experiences and solutions related to MATLAB plotting techniques.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • Max seeks assistance in plotting a potential function in MATLAB, noting the different plots for \(m^2 > 0\) and \(m^2 < 0\).
  • Yuu suggests using the surf() function in MATLAB and provides a link for additional information.
  • Max shares an initial attempt at coding the function but encounters an error related to matrix operations in MATLAB.
  • Max later resolves the issue by using meshgrid to create the necessary matrices for plotting.

Areas of Agreement / Disagreement

The discussion does not present any significant disagreements. Participants generally agree on the approach to plotting the function in MATLAB, with Max successfully resolving the initial coding issue.

Contextual Notes

Max's initial error was due to incorrect matrix operations in MATLAB, which was later corrected by using meshgrid to define the input variables properly.

maxtor101
Messages
22
Reaction score
0
Hi all,

I would like to be able to plot this function in MATLAB\mathcal{V} (\phi_{1}, \phi_{2}) = m^2(\phi_{1}^2 + \phi_{2}^2) + \lambda( \phi_{1}^2 + \phi_{2}^2)^2Where \phi_{1,2} , m^2 , \lambda \in \mathbb{R} and \lambda &gt; 0I am aware that the cases m^2 &gt; 0 and m^2 &lt; 0 yield two different plots.

I encountered this while doing some reading on QFT, this potential was used in a Lagrangian density while trying to demonstrate spontaneous U(1) symmetry breaking.

I would really like to be able to plot this in MATLAB but unfortunately I have minimal previous experience with it.

Would anybody here be able to help me please?

Thanks
Max
 
Physics news on Phys.org
Hello Maxtor,

I believe the surf() function in MATLAB to be suited for your purposes.

After defining \phi_1, \phi_2, V in MATLAB you would use it in this way:
surf(phi_1, phi_2, V). Information and examples are available here:

http://www.mathworks.de/de/help/matlab/ref/surf.html

All the best,
Yuu
 
Last edited by a moderator:
Thank you for your reply!

phi1 = [-20:0.5:20];
phi2 = [-20:0.5:20];
lam = 1;
m = 1;

V = (m^2)*(phi1.^2 + phi2^2) + lam*(phi1.^2 + phi2.^2).^2 ;


surf(phi1, phi2, V)



I tried this but I get the following error:

Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.

Error in p1a (line 6)
V = (m^2)*(phi1.^2 + phi2^2) + lam*(phi1.^2 + phi2.^2).^2 ;
 
Apologies, I got it working[phi1, phi2] = meshgrid(-20:0.5:20);

lam = 1;
m = 1;

V = (m^2)*(phi1.^2 + phi2^2) + lam*(phi1.^2 + phi2.^2).^2 ;surf(phi1, phi2, V)
thanks for your help!
 
You are very welcome :smile:
 

Similar threads

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