Omniadisce

Posts tagged Programming

153 posts match

Type
Subject
Difficulty
Tags
Show all 247 tags
Lesson
Scientific Computing Beginner Lesson

Computational physics 10.1: Where is it zero?

Some questions ask for the moment something becomes zero: the height of a ball, when it lands. That moment is a root of a function. Write the function, plot it, see where it crosses zero, and findโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 10.3: When to stop halving

Halve until the interval is narrower than a tolerance you choose, and count the halvings. Then put bisection in a function that takes another function, and use it on any root. Twenty halvings was aโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 10.6: Where forces balance

Two forces balance where their difference is zero: a root. Find the point between the Earth and the Moon where their pulls cancel, check it against an exact answer, and find a car's top speed, whereโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 11.1: Areas from strips

The area under a velocity-time graph is the distance gone. From a table of speeds, cut the area into strips, work out each one as a trapezoid, and add them up in a loop. A car's computer doesn'tโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 11.4: Simpson's rule

Take the strips in pairs and lay a curve, not a straight line, over each pair: Simpson's rule, h/3 ร— (left + 4 ร— middle + right). Slices that step by 2 pick the readings, and the error shrinks 16โ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 12.3: np.linalg.solve

np.linalg.solve(A, b) does the elimination for you, for any number of equations. Solve the circuit, check the answer by putting it back, and solve one with four unknowns that would take a page byโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 12.4: The brightest lamp

Put np.linalg.solve inside a function and call it in a loop: the same two batteries with lamps of every resistance. Plot the lamp's power, and find the lamp that glows brightest. Which lamp glowsโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 12.6: Two blocks swinging

Let the blocks go, and step them both with Eulerโ€“Cromer. Pull one block and its swing passes to the other and back; pull both together, or opposite ways, and they keep one rhythm: the normalโ€ฆ

0 views by Weten 8 days ago
× Enlarged view