subject
Engineering, 13.03.2020 19:52 pearlielb

In pyhton!

We could, in principle, represent a polynomial as a list. For instance, we could write

1+2x−3x2+2x41+2x−3x2+2x4

as

[ 1,2,-3,0,2
where the ith index corresponds to xixi . If we wrote a polynomial this way, we would also like an easy way to evaluate that polynomial for a specified value of xx ; i. e., for x=1.5x=1.5 ,

1+2×1.5−3×1.52+2×1.54=7.3751+2×1.5− 3×1.52+2×1.54=7.375

Compose a function polyeval( coefs, x ) which accepts a list of polynomial coefficients from lowest to highest order (as above) and a value x at which to evaluate the polynomial, and returns a float corresponding to the value of the polynomial evaluated at x.

A good way to start your code would be:

def polyeval( coefs, x ):
value = ??? # an accumulator pattern
# with some kind of loop here
return value
For instance, polyeval( [ 1,1,0,1 ],1 ) (1+x+x31+x+x3 for x=1x=1 ) should return 3.0. polyeval( [ 0,1,0,-2,1 ],-1 ) (x−2x3+x4x−2x3+x4 for x=−1x=−1 ) should return 2.0.

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 14:10
Line joining liquid phase with liquid and solid phase mixture is known as: a) liquidus b) solidus c) tie line d) none of the mentioned
Answers: 2
question
Engineering, 03.07.2019 15:10
Two flowing streams of argon gas are adiabatically mixed to form a single flow/stream. one stream is 1.5 kg/s at 400 kpa and 200 c while the second stream is 2kg/s at 500 kpa and 100 ? . it is stated that the exit state of the mixed single flow of argon gas is 150 c and 300 kpa. assuming there is no work output or input during the mixing process, does this process violate either the first or the second law or both? explain and state all your assumptions.
Answers: 1
question
Engineering, 04.07.2019 18:10
If a particle moves along a path such that r : (3 sin t) m and ? : 2t rad, where t is in seconds. what is the particle's acceleration in m/s in 4 seconds? a)- 16.43 b)- 16.29 c)- 15.21 d)- 13.79
Answers: 1
question
Engineering, 04.07.2019 18:10
Abrake has a normal braking torque of 2.8 kip in and heat-dissipating cast-iron surfaces whose mass is 40 lbm. suppose a load is brought to rest in 8.0 s from an initial angular speed of 1600 rev/min using the normal braking torque; estimate the temperature rise of the heat dissipating surfaces.
Answers: 3
You know the right answer?
In pyhton!

We could, in principle, represent a polynomial as a list. For instance, we co...
Questions
question
Mathematics, 23.03.2021 01:00
question
Mathematics, 23.03.2021 01:00
question
Mathematics, 23.03.2021 01:00
Questions on the website: 13722360