Area Under Curves and Volume of Revolving a Curve Discussions | Functional Programming | HackerRank

Area Under Curves and Volume of Revolving a Curve

Sort by

recency

|

119 Discussions

|

  • + 0 comments

    scala:

      private val dx = 0.001
      def readLine() = scala.io.StdIn.readLine()
    
      def f(coefficients: Seq[Int], powers: Seq[Int], x: Double) = {
        (coefficients zip powers)
          .map { case (a, b) => a * math.pow(x, b) }
          .sum
      }
    
      def area(coefficients: Seq[Int], powers: Seq[Int], x: Double): Double = {
        Math.PI * Math.pow(f(coefficients, powers, x), 2)
      }
    
      def summation(
          func: (Seq[Int], Seq[Int], Double) => Double,
          upperLimit: Int,
          lowerLimit: Int,
          coefficients: Seq[Int],
          powers: Seq[Int]
      ): Double = {
        val steps = ((upperLimit - lowerLimit) / dx).toInt
        val range = (0 to steps).map(lowerLimit + _ * dx)
        val result = range
          .map(func(coefficients, powers, _) * dx)
          .sum
        BigDecimal(result).setScale(1, BigDecimal.RoundingMode.UP).toDouble
      }
    
  • + 0 comments

    Haskell concise solution solve :: Int -> Int -> [Int] -> [Int] -> [Double] solve l r as bs = [sum [(f as bs i) * dx|i<-range], sum [pi*(f as bs i)^^2 * dx|i<-range]] where dx = 0.001 fl = fromIntegral l fr = fromIntegral r range = [fl,fl+dx..fr] f as bs x = sum[(fromIntegral a)*(x^^b)|(a,b)<-zip as bs]

  • + 1 comment

    Calculating the area under curves and the volume of revolving a curve involves integration techniques. Just as Racine Nail achieves flawless designs with precision, mastering these calculus concepts ensures perfect mathematical solutions.

  • + 0 comments

    "Exploring the intricacies of calculus through understanding the area under curves and the volume obtained by revolving them offers profound insights into mathematical abstraction and real-world applications." Cricbet99 Login ID and Password

  • + 0 comments

    Exploring the area under curves and volume of shapes formed by revolving curves adds a fascinating dimension to understanding mathematical concepts. Cricbet99 id