Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Homework Help
Engineering and Comp Sci Homework Help
Interpolation and linear algebra
Reply to thread
Message
[QUOTE="mafagafo, post: 4932720, member: 496548"] [h2]Homework Statement [/h2] As a string in my program. [h2]Homework Equations[/h2] Solving a system with the forward phase of row echelon reduction and a consecutive back substitution. All done by numpy here. (The book suggested MATLAB, etc). [h2]The Attempt at a Solution[/h2] [code=python]import numpy """ In a wind tunnel experiment, the force on a projectile due to air resistance was measured at different velocities: Velocity (100 ft/sec) 0 2.00 4.00 6.00 8.00 10.00 Force (100 lb) 0 2.90 14.8 39.6 74.3 119.0 Find an interpolating polynomial for these data and estimate the force on the projectile when the projectile is traveling at 750 ft/sec. Use p(t) = a0 + a1*t + a2*t^2 + a3*t^3 + a4*t^4 + a5*t^5. What happens if you try to use a polynomial of degree less than 5? (Try a cubic polynomial, for instance.) """ make_row_for_t = lambda t: [t ** n for n in range(6)] A = numpy.array([make_row_for_t(t * 100) for t in range(0, 11, 2)]) B = numpy.array([[n] for n in [0, 290, 1480, 3960, 7430, 11900]]) coefficients = numpy.linalg.solve(A, B) p = numpy.polynomial.Polynomial(coefficients.flatten()) print_p = lambda x: print("{:<8} = {}".format("p(" + str(x) + ")", p(x))) for n in range(0, 1100, 200): print_p(n) print_p(750)[/code] [SPOILER="Output"] [code]p(0) = 0.0 p(200) = 290.0000000000015 p(400) = 1480.0000000000023 p(600) = 3960.0000000000036 p(800) = 7430.000000000004 p(1000) = 11900.00000000001 p(750) = 6483.837890625005[/code] [/SPOILER] Did it work? Yes. (Just get the python3 and python3-numpy packages under Linux and it should run in your machine too.) The book does not have the answer, but mine seems OK, I wanted to get some review on what I did as I am new to numpy and interpolation and thought I would get some useful advice or even corrections. [/QUOTE]
Insert quotes…
Post reply
Forums
Homework Help
Engineering and Comp Sci Homework Help
Interpolation and linear algebra
Back
Top