Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Regra-trapezio
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
f<-function(s){1/(1+s^2)} curve(f,-5,5) x=seq(-5,5,by=0.01); y=f(x) points(x,y,col="red") # Cálculo de integral pela regra dos trapézios Trap<-function(f,v){ # Regra dos trapézios n=length(v) trap=0 for ( i in 1:(n-1)){trap=trap+(f(v[i])+f(v[i+1]))*(v[i+1]-v[i])/2} trap } print("Aproximação para a integral"); print(Trap(f,seq(-5,5,by=0.01)),digits=22) print(atan(5)-atan(-5),digits=22)
[
+
]
Show input
Absolute running time: 0.72 sec, cpu time: 0.9 sec, memory peak: 49 Mb, absolute service time: 0,95 sec
edit mode
|
history
|
discussion
[1] "Aproximação para a integral" [1] 2.746801287341879671544 [1] 2.746801533890031787877 [1] 0