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, 04.07.2019 18:10
The temperature of air decreases as it is compressed by an adiabatic compressor. a)- true b)- false
Answers: 2
question
Engineering, 04.07.2019 18:10
Apipe with an outside diameter of 15 cm is exposed to an ambient air and surrounding temperature of -20°c. the pipe has an outer surface temperature of 65°c and an emissivity of 0.85. if the rate of heat loss from the pipe surface is 0.95 kw per meter of length, the external convective heat transfer coefficient (h) is: (a) 12.5 w/m"k (b) 18.6 w/mk (c) 23.7 w/mk (d) 27.9 w/mk (e) 33.5 w/mk
Answers: 1
question
Engineering, 04.07.2019 18:10
At 12 noon, the count in a bacteria culture was 400; at 4: 00 pm the count was 1200 let p(t) denote the bacteria cou population growth law. find: (a) an expression for the bacteria count at any time t (b) the bacteria count at 10 am. (c) the time required for the bacteria count to reach 1800.
Answers: 1
question
Engineering, 04.07.2019 18:20
Refrigerant-134a enters the compressor of a refrigerator as superheated vapor at 0.14 mpa and -10°c at a rate of 0.05 ka/s and leaves at 0.8 mpa and 50°c. the refrigerant is cooied in the condenser to 0.72 mpa and 26'c. it is then throttled to 0.15 mpa. sketch the t-s diagram for the system and evaluate: 6) the rate of heat removai from the refrigerated space (kw), it) the power input to the compressor (kw), ii) the isentropic efficiency of the compressor (%), and iv) the cop of the refrigerator.
Answers: 2
You know the right answer?
In pyhton!

We could, in principle, represent a polynomial as a list. For instance, we co...
Questions
question
Mathematics, 14.02.2021 21:00
question
Engineering, 14.02.2021 21:00
question
Biology, 14.02.2021 21:00
question
Mathematics, 14.02.2021 21:00
question
Mathematics, 14.02.2021 21:00
Questions on the website: 13722362