can somone write the code for Quadratic spline interpolation in javascript \" EC
ID: 3837301 • Letter: C
Question
can somone write the code for Quadratic spline interpolation in javascript " ECMASCRIPT "
Define the data points 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]]
Using these points,build the quadratic spline interpolation piecewise continuous and differentiable set of quadratic polynomials that go through those points and evaluate the function at x=1.5.
Connect the first two points with a straight line. Then use the ending point and slope together with the following point to build the quadratic equation using the attached Cramer's Rule function.
Keep repeating this until your last interval includes the value x. Use the that quadratic function to calculate the value of y.
Cramer's rule function:
{ y = -5x2 -2x -6 } is (0,-6),-2,(1,-13) is { y = -5x2 -2x -6 }
{ y = -5x2 -2x -3 } is (0,-3),-2,(1,-10) is { y = -5x2 -2x -3 }
{ y = -5x2 -2x } is (0,0),-2,(1,-7) is { y = -5x2 -2x }
{ y = -5x2 -2x +3 } is (0,3),-2,(1,-4) is { y = -5x2 -2x +3 }
{ y = -5x2 -6 } is (0,-6),0,(1,-11) is { y = -5x2 -6 }
{ y = -5x2 -3 } is (0,-3),0,(1,-8) is { y = -5x2 -3 }
{ y = -5x2 } is (0,0),0,(1,-5) is { y = -5x2 }
{ y = -5x2 +3 } is (0,3),0,(1,-2) is { y = -5x2 +3 }
{ y = -5x2 +2x -6 } is (0,-6),2,(1,-9) is { y = -5x2 +2x -6 }
{ y = -5x2 +2x -3 } is (0,-3),2,(1,-6) is { y = -5x2 +2x -3 }
{ y = -5x2 +2x } is (0,0),2,(1,-3) is { y = -5x2 +2x }
{ y = -5x2 +2x +3 } is (0,3),2,(1,0) is { y = -5x2 +2x +3 }
{ y = -2x -6 } is (0,-6),-2,(1,-8) is { y = -2x -6 }
{ y = -2x -3 } is (0,-3),-2,(1,-5) is { y = -2x -3 }
{ y = -2x } is (0,0),-2,(1,-2) is { y = -2x }
{ y = -2x +3 } is (0,3),-2,(1,1) is { y = -2x +3 }
{ y = -6 } is (0,-6),0,(1,-6) is { y = -6 }
{ y = -3 } is (0,-3),0,(1,-3) is { y = -3 }
{ y = 0 } is (0,0),0,(1,0) is { y = 0 }
{ y = 3 } is (0,3),0,(1,3) is { y = 3 }
{ y = 2x -6 } is (0,-6),2,(1,-4) is { y = 2x -6 }
{ y = 2x -3 } is (0,-3),2,(1,-1) is { y = 2x -3 }
{ y = 2x } is (0,0),2,(1,2) is { y = 2x }
{ y = 2x +3 } is (0,3),2,(1,5) is { y = 2x +3 }
{ y = 5x2 -2x -6 } is (0,-6),-2,(1,-3) is { y = 5x2 -2x -6 }
{ y = 5x2 -2x -3 } is (0,-3),-2,(1,0) is { y = 5x2 -2x -3 }
{ y = 5x2 -2x } is (0,0),-2,(1,3) is { y = 5x2 -2x }
{ y = 5x2 -2x +3 } is (0,3),-2,(1,6) is { y = 5x2 -2x +3 }
{ y = 5x2 -6 } is (0,-6),0,(1,-1) is { y = 5x2 -6 }
{ y = 5x2 -3 } is (0,-3),0,(1,2) is { y = 5x2 -3 }
{ y = 5x2 } is (0,0),0,(1,5) is { y = 5x2 }
{ y = 5x2 +3 } is (0,3),0,(1,8) is { y = 5x2 +3 }
{ y = 5x2 +2x -6 } is (0,-6),2,(1,1) is { y = 5x2 +2x -6 }
{ y = 5x2 +2x -3 } is (0,-3),2,(1,4) is { y = 5x2 +2x -3 }
{ y = 5x2 +2x } is (0,0),2,(1,7) is { y = 5x2 +2x }
{ y = 5x2 +2x +3 } is (0,3),2,(1,10) is { y = 5x2 +2x +3 }
{ y = 4.9375x2 -20x } : (-4, 159) (-3, 104.4375) (-2, 59.75) (-1, 24.9375) (0, 0) (1, -15.0625) (2, -20.25) (3, -15.5625) (4, -1) (5, 23.4375) (6, 57.75) (7, 101.9375)
Explanation / Answer
import turingMachine.State;
import turingMachine.Transition;
import turingMachine.TuringMachine;
/**
* electronic computer
* Coded by emir El Bawab
* Date: three January 2015
* License: university License ~ Please browse License.txt for a lot of info concerning the usage of this software system
* */
public category AcceptReject produce the machine which will solely settle for 1's
TuringMachine atomic number 69 = new TuringMachine('q');
// produce the states
State[] alphabetic character = new State[3];
q[0] = tm.addState(State.INITIAL);
q[1] = tm.addState(State.FINAL);
q[2] = tm.addState(State.NORMAL);
// Add transition
tm.addTransition(q[0], q[0], '1', '1', Transition.RIGHT);
tm.addTransition(q[0], q[1], Transition.BLANK, Transition.BLANK, Transition.LEFT);
tm.addTransition(q[0], q[2], '0', '0', Transition.RIGHT);
// method input 111
if(tm.process("111")) // settle for as a result of solely 1's
System.out.println("Accept 111");
else
System.out.println("Reject 111");
// method input 1011
if(tm.process("1011")) // Reject as a result of there is a zero
System.out.println("Accept 1011");
else
System.out.println("Reject 1011");
}
}
import java.io.FileNotFoundException;
import turingMachine.TuringMachine;
/**
* Turing Machine
* Coded by Amir El Bawab
* Date: three January 2015
* License: university License ~ Please browse License.txt for a lot of info concerning the usage of this software system
* */
public category Addition {
public static void main(String[] args) {
try {
// Import addition machine
TuringMachine addition = TuringMachine.inParser("addition");
// Print addition machine
System.out.println("Machine content:");
System.out.println(addition);
// method input
addition.process("1011");
// Print the tape content once the method
System.out.println("Tape content once process '1011':");
System.out.println(addition.getTapeSnapshot());
} catch (FileNotFoundException e)
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.