Answers for "how to do x root 3 on java"

0

java bigdecimal third root

public static long ITER = 1000;

  public static BigDecimal cuberoot(BigDecimal b) {
      // Specify a math context with 40 digits of precision.

      MathContext mc = new MathContext(40);

      BigDecimal x = new BigDecimal("1", mc);

      // Search for the cube root via the Newton-Raphson loop. Output each // successive iteration's value.

      for (int i = 0; i < ITER; i++) {
          x = x.subtract(
                  x.pow(3, mc)
                          .subtract(b, mc)
                          .divide(new BigDecimal("3", mc).multiply(
                                  x.pow(2, mc), mc), mc), mc);
      }
      return x;
  }
Posted by: Guest on May-30-2020
0

how to do 4th root java

import java.io.*;import 
java.util.Scanner;import
java.lang.*;
class FourthRoot
{
  public static void main(String[] args)   
    {    
    	Scanner in = new Scanner(System.in);    
    	double p,a=10;    
    	p=Math.pow(a,(0.25));   
    	System.out.println("Fourth Root "+p);  
  	}
}
Posted by: Guest on June-01-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language