Preparing for a Physics Degree: The Role of Programming in High School

In summary,If you want to do physics,focus next on the physicsnot on the packages and libraries.The nature of the physics problem determines the tools that one needs.
  • #1
Philip551
16
5
How can a high school student prepare for a physics degree with programming. i.e. which programming language, what packages?
 
  • Like
Likes berkeman
Physics news on Phys.org
  • #2
Philip551 said:
How can a high school student prepare for a physics degree with programming. i.e. which programming language, what packages?
There are many answers depending on where you end up, and what you will be requested to solve. I think the best recommendation at this stage of yours is: learn Python. You can't go wrong with it and it will be of value even if the path of your life might become a different one. It teaches all programming basics which can also be used in other languages.
 
  • Like
Likes PhDeezNutz
  • #3
fresh_42 said:
There are many answers depending on where you end up, and what you will be requested to solve. I think the best recommendation at this stage of yours is: learn Python. You can't go wrong with it and it will be of value even if the path of your life might become a different one. It teaches all programming basics which can also be used in other languages.
I already have a good grasp of python programming and coding fundementals. I am looking to better expand skills in things like data analysis and visualisation. Also was thinking of starting R.
 
  • #4
Philip551 said:
I already have a good grasp of python programming and coding fundementals. I am looking to better expand skills in things like data analysis and visualisation. Also was thinking of starting R.
With "good grasp of python programming and coding fundamentals", the next step is
to apply them to solving physics problems...
...if you want to be a physics major and doing programming with it.
What data to analyze and visualize depends on the physics being modeled.

If you want to do physics,
then focus next on the physics
not on the packages and libraries.
The nature of the physics problem determines the tools that one needs.The physics undergrads I am teaching this semester are using this variant of Python:
https://www.glowscript.org/
as part of the Matter and Interactions https://matterandinteractions.org/ curriculum
 
  • Informative
  • Like
Likes Philip551, fresh_42 and berkeman
  • #5
Philip551 said:
How can a high school student prepare for a physics degree with programming. i.e. which programming language, what packages?
Philip551 said:
I already have a good grasp of python programming and coding fundementals. I am looking to better expand skills in things like data analysis and visualisation. Also was thinking of starting R.
It sounds like you are in a good place. Keep up the great work! :smile:

You might look into the area of Numerical Methods. It's a bit advanced, but it sounds like you are in a good place and it probably applies to what you've said is your career goal.

https://en.wikipedia.org/wiki/Numerical_analysis
 
  • Like
Likes Philip551, vela, PhDeezNutz and 1 other person
  • #6
Philip551 said:
I already have a good grasp of python programming and coding fundementals. I am looking to better expand skills in things like data analysis and visualisation. Also was thinking of starting R.
You could learn MATLAB then. Here is quite a good course (I have it available free through my University, so not sure if it'll be of use to you) https://www.coursera.org/specializations/matlab-programming-engineers-scientists . But it goes through the basics in the first module, and culminates with 'Introduction to Data, Signal, and Image Analysis with MATLAB' in third module.

If you've experience with Python then you'll likely fly through the first module.
 
  • Informative
Likes Philip551
  • #7
Philip551 said:
I already have a good grasp of python programming and coding fundementals

Do you?

Do you understand the difference between an array, a vector, a list and a deque? Can you quantify how much faster a heapsort is than a bubble sort?
 
  • #8
I asked my freshman (physics college) advisor the same question 50 years ago: "should I take a programming course?". His response was: "No, don't bother, you will learn what need when you need it".
Since he helped produce the first atomic bomb I figured he knew how to use time effectively and indeed he was correct.
 
Last edited:
  • Like
  • Wow
Likes jedishrfu and Philip551
  • #9
Philip551 said:
How can a high school student prepare for a physics degree with programming. i.e. which programming language, what packages?

You might want to wait to see how programming can help you first rather than committing to an unfocused effort. You would be better off at this stage in your education to put more emphasis on developing a sound foundation in the math you will need.
 
  • Like
Likes Philip551 and hutchphd
  • #10
hutchphd said:
I asked my freshman (physics college) advisor the same question 50 years ago: "should I take a programming course?". His response was: "No, don't bother, you will learn what need when you need it"

I think that times have changed in 50 years. It is an essential skill for most physicists to cobble some code together than mostly sort of works. It is a desirable skill to be able to actually program.
 
  • #11
I learned what I needed as I needed. Better he study the math as @gleem suggests.

To quote Nowhere Man:

 
  • #12
The point I should have made is that programming may help you do physics but programming does not help you to learn physics. Today there are so many software packages available to perform useful tasks that it is only when you get a unique problem that you may need to develop custom software. It is more important to understand what the program needs to do than to be a great coder without that understanding.
 
  • Like
Likes hutchphd and symbolipoint
  • #13
gleem said:
The point I should have made is that programming may help you do physics but programming does not help you to learn physics. Today there are so many software packages available to perform useful tasks that it is only when you get a unique problem that you may need to develop custom software. It is more important to understand what the program needs to do than to be a great coder without that understanding.

As I said above, if physics is the goal,
then one should try next to apply the programming to a physics problem.
The computer program is a model of a physical situation.
In my opinion, this is a more physics-focused task than some other computer-programming task (like sorting).

I would say a similar thing about mathematics.

Why do either in isolation from the physics?
Applying programming and mathematics to modeling a physical situation
can help both develop programming and mathematics skill needed for physics.I think programming can help you learn physics.
While I can solve problems, I feel I understand the situation even better
when I can tell a computer to model a physical situation
because a higher level of precision of ideas is needed.

The following viewpoint by Chabay and Sherwood (associated with https://matterandinteractions.org/ and https://www.glowscript.org/) might be enlightening.
Their goal is to emphasize the "sense of mechanism" involving basic fundamental interactions,
and suggest that iterative thinking helps.

Thinking Iteratively
 
Last edited:
  • Like
  • Informative
Likes Philip551 and vela
  • #14
gleem said:
You might want to wait to see how programming can help you first rather than committing to an unfocused effort. You would be better off at this stage in your education to put more emphasis on developing a sound foundation in the math you will need.
It doesn't have to be an either-or situation. When I was in 8th grade, I taught myself APL, and in doing so, I learned a lot of math along the way.

I'll echo what @robphy said. Find an interesting problem to solve with the help of a computer. If you pick a physics problem, you'll probably learn some physics, some new math, and how to program in whatever language you choose. I think this process will provide one with a more organic learning experience than sitting down with a book to learn how to program in a specific language.
 
  • Like
  • Informative
Likes Philip551, hutchphd and robphy
  • #15
Vanadium 50 said:
I think that times have changed in 50 years. It is an essential skill for most physicists to cobble some code together than mostly sort of works. It is a desirable skill to be able to actually program.
That is for smart people. Those who need more help could use formal instruction for how to use a language and create or design computer programs.
 
  • #16
robphy said:
With "good grasp of python programming and coding fundamentals", the next step is
to apply them to solving physics problems...
...if you want to be a physics major and doing programming with it.
What data to analyze and visualize depends on the physics being modeled.

If you want to do physics,
then focus next on the physics
not on the packages and libraries.
The nature of the physics problem determines the tools that one needs.The physics undergrads I am teaching this semester are using this variant of Python:
https://www.glowscript.org/
as part of the Matter and Interactions https://matterandinteractions.org/ curriculum
I was not sure of how to tie the physics with the programming together.

I started glowscript and found it being much more enjoyable than simply learning coding skills.

I found a great course on it. https://bphilhour.trinket.io/physic...d-the-3d-environment/welcome-and-introduction
 
  • Like
Likes robphy
  • #17
Irishdoug said:
You could learn MATLAB then. Here is quite a good course (I have it available free through my University, so not sure if it'll be of use to you) https://www.coursera.org/specializations/matlab-programming-engineers-scientists . But it goes through the basics in the first module, and culminates with 'Introduction to Data, Signal, and Image Analysis with MATLAB' in third module.

If you've experience with Python then you'll likely fly through the first module.
I was thinking of starting a programming language of that sort, so thanks for the suggestion.
 
  • #18
Philip551 said:
I was not sure of how to tie the physics with the programming together.

I started glowscript and found it being much more enjoyable than simply learning coding skills.

I found a great course on it. https://bphilhour.trinket.io/physic...d-the-3d-environment/welcome-and-introduction

I feel the same way.
My motivation to code was because
I want to focus on using the computer to solve physics problems,
learning more coding when my code needed to do something more.

I took computer science courses in college and C++programming in grad school.
I didn't really enjoy what I was doing because the topics were on general computational tasks
(like sorting algorithms or understanding object-oriented thinking) [which are important skills
and I learned a lot].
I wanted to spend more time working on modeling a physics situation
rather than (for example) creating a program that plays blackjack.

Deep in glowscript.org,
you can find
https://www.glowscript.org/#/user/GlowScriptDemos/folder/matterandinteractions/
code that gets used in the Matter and Interactions text (calculus-based introductory physics, emphasizing computation and a more modern approach to introductory physics).

Here's an example of some glowscript that I've done
PushMePullYou-motionUpdate - https://trinket.io/library/trinkets/754fee393c
(google: push me pull you mit )
Doppler-MovingSource-approaching - https://trinket.io/library/trinkets/6b2b9ad98b

(My avatar was created using an ancient version of VPython [glowscript is basically VPython in a browser].
And I have some very old VPython code ( http://www.visualrelativity.com/vpython/ ) that I need to revise into Glowscript programs.)
 
  • Like
Likes Philip551
  • #19
Many schools turn to MATLAB as the go-to for programming in STEM. It has a lot going for it. From MATLAB's perspective, it makes sense to sell it cheaply to students and then to soak the companies that hire these students with copies that are many times more expensive.

https://www.amazon.com/dp/0081029977/?tag=pfamazon01-20

Python is another language that is taught in school. It is the defacto Machine Learning language. Coupled with numpy, scipy and matplotlib for charting it can tackle any and all physics simulations.

Java is another language too that has gained traction. Instructors will want you to learn Eclipse IDE for coding and debug. There is an excellent book by Tobochnik on doing Java-based physics simulations.

https://www.amazon.com/dp/0805377581/?tag=pfamazon01-20

And then there's Julia which I feel is the future for education. Its MIT developed, it has the feel of MATLAB, it's fast, it supports the notebook interface. Books are starting to come out on Julia's capabilities such as Algorithms for Optimization by Kochenderfer.

https://www.amazon.com/dp/0262039427/?tag=pfamazon01-20

Pick one, you may well use most or all of them in college.
 
  • Like
  • Informative
Likes PhDeezNutz and Philip551
  • #20
  • Like
Likes PhDeezNutz
  • #21
If you feel comfortable with Python, learn numpy, scipy and matplotlib as jedishrfu mentioned above. You might find sympy handy and you don't need to delve very deeply into pandas and scikit-learn before putting them to use with lab data.
 
  • Informative
Likes Philip551

1. What is the relationship between a physics major and programming?

A physics major involves studying the fundamental laws and principles that govern the universe, while programming involves creating and manipulating computer software. However, there is a strong overlap between the two fields as many concepts in physics, such as mathematical modeling and data analysis, are essential in programming. Additionally, programming is becoming increasingly important in the field of physics as it allows for simulations and data analysis that would be impossible to do by hand.

2. Do I need to have a background in programming to major in physics?

No, a background in programming is not required to major in physics. However, having some knowledge of programming can be beneficial as it will allow you to better understand and apply concepts in physics, and it will also make you more competitive in the job market.

3. What programming languages are most commonly used in physics?

The most commonly used programming languages in physics are Python, C++, and Fortran. Python is often used for data analysis and visualization, while C++ and Fortran are used for more complex simulations and calculations.

4. How can programming skills be applied in a physics career?

Programming skills can be applied in a variety of ways in a physics career. For example, you can use programming to analyze and visualize data, create simulations to test theoretical models, or develop software for scientific instruments. Many industries, such as aerospace and technology, also value individuals with both physics and programming skills.

5. Are there any specific courses or resources that can help me learn programming as a physics major?

Yes, many universities offer courses specifically designed for physics majors to learn programming, such as "Computational Physics" or "Numerical Methods in Physics". There are also online resources and tutorials available, such as Codeacademy and Coursera, that can help you learn programming at your own pace.

Similar threads

  • STEM Academic Advising
Replies
16
Views
2K
Replies
6
Views
960
  • STEM Academic Advising
Replies
9
Views
850
  • STEM Academic Advising
Replies
4
Views
1K
  • STEM Academic Advising
Replies
5
Views
821
  • STEM Academic Advising
2
Replies
50
Views
4K
  • STEM Academic Advising
Replies
3
Views
438
  • STEM Academic Advising
Replies
3
Views
796
  • STEM Academic Advising
Replies
16
Views
1K
  • STEM Academic Advising
Replies
6
Views
1K
Back
Top