Question: I am trying to write a code in javascript to evaluate lagrange polynomial at x=1.5 that passes through given points. Here is the assignment

I am trying to write a code in javascript to evaluate lagrange polynomial at x=1.5 that passes through given points. Here is the assignment "

Define the data points and the value of x in variables that can be easily replaced, like this:

p = [[0,3.8414709848078967],[0.6931471805599453,6.6818861490654635],[1.0986122886681098,7.5355691627323065],[1.3862943611198906,7.788374949171635],[1.6094379124341003,8.478827375073264],[1.791759469228055,9.887622378713294],[1.9459101490553132,11.440627194940042],[2.0794415416798357,12.307124413342725]]

x = 1.5

all I need you to display is the value of f(x)."

The problem is that I get the output "NaN".

This is what I have so far:

How can I fix this?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!