r/learnpython • u/Current_Beginning_39 • 42m ago
How to solve python problems?
This may be a dumb questions, but I do not get how to write code. For some context, I am taking a scientific computing course in my uni, I am a physics major, so most of the coding we do pertains to some kinda physics/math related problem. I know how to do the math on its own but I don't get how to translate it into code. When I see a problem I don't even know how to start it.
For example:
Write a function my_cubic_spline_flat(x, y, X), where x and y are arrays containing experimental data points, and X is an array. Assume that x and X are in ascending order and have unique elements. The output argument, Y, should be an array, the same size as X, where Y[i] is the cubic spline interpolation of X[i]. However, instead of the constraints we introduced before, 𝑆′1(𝑥_1)=0 and 𝑆′𝑛−1(𝑥_𝑛)=0.
When I see that, I do not know what to do. Like I know how to write functions and stuff, but not the actual code that goes inside the function.
Any advice is appreciated! :)
View all comments
•
u/lurgi 38m ago
Do you know what a cubic spline is?