Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
FindMissingLagrange
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//g++ 7.4.0 //Interpolation: Lagrange Method //code is created by Rezaul Hoque on January 13 , 2021 //please contact at jewelmrh@yahoo.com //if x advances by unequal interval then Lagrange method is used for interpolation #include <iostream> using namespace std; int main () { int n=5; float x[n]={0,2,3,5,6}; float y[n]={5,7,8,10,12}; float corrX, missY; corrX=4; missY =( y[0]*(corrX-x[1])*(corrX-x[2])*(corrX-x[3])*(corrX-x[4]))/((x[0]-x[1])*(x[0]-x[2])*(x[0]-x[3])*(x[0]-x[4])) + ( y[1]*(corrX-x[0])*(corrX-x[2])*(corrX-x[3])*(corrX-x[4]))/((x[1]-x[0])*(x[1]-x[2])*(x[1]-x[3])*(x[1]-x[4])) + ( y[2]*(corrX-x[1])*(corrX-x[0])*(corrX-x[3])*(corrX-x[4]))/((x[2]-x[1])*(x[2]-x[0])*(x[2]-x[3])*(x[2]-x[4])) + ( y[3]*(corrX-x[1])*(corrX-x[2])*(corrX-x[0])*(corrX-x[4]))/((x[3]-x[1])*(x[3]-x[2])*(x[3]-x[0])*(x[3]-x[4]))+( y[4]*(corrX-x[1])*(corrX-x[2])*(corrX-x[3])*(corrX-x[0]))/((x[4]-x[1])*(x[4]-x[2])*(x[4]-x[3])*(x[4]-x[0])); cout <<"The missing y is "<<missY<<endl; return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.32 sec, absolute running time: 0.15 sec, cpu time: 0.01 sec, memory peak: 5 Mb, absolute service time: 0,51 sec
edit mode
|
history
|
discussion
The missing y is 8.88889