Mavzu: Taqribiy integrallash usullari. Zaruriy aniqlikni ta’minlovchi qadamni tanlash
Download 63.49 Kb.
|
4-amaliyot
Mavzu: Taqribiy integrallash usullari. Zaruriy aniqlikni ta’minlovchi qadamni tanlash Azadov Ruslanbek 912-21 guruh talabasi object Chap { fun f(x: Double): Double { val d = Math.sqrt(0.5 * x + 2) /(Math.sqrt(1.5 * x * x + 2) +0.8) return d } @JvmStatic fun main(args: Array val a = 0.4 val b = 1.2 val n = 1000 val h = (b - a) / n var s = 0.0 var x = a + h / 2 while (x < b) { s += f(x) x += h } s *= h println(s) } } package com.company.Amaliy import kotlin.math.pow
fun k(x: Double): Double { val d = Math.sqrt(0.5 * x + 2) /(Math.sqrt(1.5 * x * x + 2) +0.8) return d } fun main() { val a = 0.4 val b = 1.2 val n = 1000 val h = (b - a) / n var x = a + h / 2 var s = k(x) for (i in 1 until n) { x += h s += k(x) } s *= h println(s) }
import java.util.Scanner fun F(x: Double): Double { val f = Math.sqrt(0.5 * x + 2) /(Math.sqrt(1.5 * x * x + 2) +0.8) return f } fun main(args: Array val input = Scanner(System.`in`) var a: Double = 0.4 var b: Double = 1.2 var n: Int = 1000 val h = (b - a) / n var x = a var s = F(x) for (i in 1 until n) { x += h s += F(x) } s *= h println("s = $s ") } Download 63.49 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling