Тёмный

Physics Python Warm Up Questions (and Answers) using Numpy 

Dot Physics
Подписаться 37 тыс.
Просмотров 655
50% 1

Here are some warm up questions for python.
1. Import numpy and matplotlib.pyplot.
2. Create an array of x-values from 0 to 1 evenly split into N = 10 spaces.
3. Create an array of values V = x2 that is the same length as x array.
4. Plot x vs. V.
5. Traverse the list of V values and set them all equal to zero except when x greater than 0.5.
6. Make a 6x6 matrix with the diagonal elements equal to 4. Give it the name M.
7. Add an off diagonal to the matrix with values -2 and add it to M.
8. Add a lower off diagonal to the matrix M with values -2.
9. Print 2 eigenvalues for the matrix M.
10. Print the first eigenvector for M.
11. Recreate the vector M and make it 99 x 99. Plot the first two eigenvectors.
12. Make an array called y from 0 to 1 with 20 spaces. Print the list without the first or last element.

Опубликовано:

 

12 окт 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 6   
@fizixx
@fizixx 8 месяцев назад
Terrific refresher. I was doing something where I wanted to print nicely indexed resistor, voltage and current values, and couldn't get colabs to do a 'len(x)'. It kept giving a fault. Never found out what happened, but I was using the command correctly, because it worked in another python application. Frustrating. Glad you found out why yours was acting up.
@unsal7290
@unsal7290 4 месяца назад
I think I know what happened when you typed "M = M -2*np.diag(np.ones(5),1)". Python creates a "second" diagonal matrix with "-2" in the diagonal (5,1) then it subtracts the value "1" from the "original" Matrix M. That's why you didn't get what you expected.
@Garglicious
@Garglicious 8 месяцев назад
Hey do you have any paid course for Computational physics or thinking about making one in future ? You're such a good teacher it would be really helpful for us beginners to intermediate level students..
@DotPhysics
@DotPhysics 8 месяцев назад
I would like to make that course - let me look into it. Also, thank you very much for your comment.
@christopherbennett1631
@christopherbennett1631 8 месяцев назад
v[v
@godphysics2473
@godphysics2473 8 месяцев назад
Great!
Далее
Едим ЕДУ на ЗАПРАВКАХ 24 Часа !
28:51
КВН 2024 Высшая лига Четвертая 1/4
1:52:57
Lesson 2: Practical Deep Learning for Coders 2022
1:16:42
10x Faster Than NumPy (GPU Magnet Simulation)
43:15
Просмотров 14 тыс.
5 Math Skills Every Programmer Needs
9:08
Просмотров 1 млн
Matplotlib Tutorial : Matplotlib Full Course
1:34:00
Просмотров 114 тыс.