Calculate square root including sum and product

Hi,
I have to enter the square root of:
Text1*Text1+Text2*Text2-2*Text1*Text2*Text3
How do i do that?
I hope someone can help me.

Thanks a million try67,
i found another way that worked as well:
event.value = Math.sqrt(+this.getField("Text1").value*this.getField("Text1").value+this.getField("Text2 ").value*this.getField("Text2").value-2*this.getField("Text1").value*this.getField("Text2" ).value*this.getField("Text3").value)
Mine is much more confuse:)

Similar Messages

  • Calculate Square Root?

    Can I use Simplified field notation to calculate the square root of another field? Not having any success.

    No. You need to use the Custom Script option, with some code like this (assuming the name of the other field is Text1):
    event.value = Math.sqrt(+this.getField("Text1").value);

  • How to calculate the Current APC (Acquisition and Production Cost)

    Hi,
    Please help me how to calculate the Current APC.
    The Current APC (Acquisition and Production Cost) is a calculated value based on Previous Year Acquisition balance plus any value changes up to the time of the report.
    The Asset History Report (RAGITT_ALV01) calculates the Current APC value &
    The Current APC can also be found in the Asset Explorer (transaction code AW01N) under Country Book 10/ Posted Values tab then the line “Acquisition Value” and column “Posted values”.
    I suppose that the calculation of Current APC (Acquisition and Production Cost) is getting done in the GET statements in the report RAGITT_ALV01, but unable to find the actual logic.
    Please help me.
    Thanks in advance,
    Satish

    Hi,
    you'll find the logic in fm FI_AA_VALUES_CALCULATE
    A.

  • How to calculate elapsed time(including time and date)?

    Hi all,
    I want to realize a function that can calculate the elapsed time which include time and date.Below is my thought:get the current time and date and store it to a .txt file then using the latest time and date subtract the time and date stored in the .txt file.how can realize it using the simplest way?I'm using LV7.1.

    Hi Idragon,
    you can do it like this.
    Mike
    Attachments:
    DateTime.PNG ‏12 KB

  • Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount 28

    Post Author: tadj188#
    CA Forum: Formula
    Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
    Background:
    1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using  subreports.    A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report    with their respective detail lines).  I had multiple subreports and each subreport became one union.
    Created and tested, already:
    1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
    Issue:
    1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
    Other Ideas Appreciated:
    1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
    Thank you.
    Tadj

    export all image of each page try like this
    var myDoc = app.activeDocument;
    var myFolder = myDoc.filePath;
    var myImage = myDoc.allGraphics;
    for (var i=0; myImage.length>i; i++){
        app.select(myImage[i]);
        var MyImageNmae  = myImage[i].itemLink.name;
        app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
        app.jpegExportPreferences.exportResolution = 300;
           app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
        alert(myImage[i].itemLink.name)

  • Square Root and Powers Assignement

    Hey guys
    Ive just started my first year at university, still feeling like ive been thrown in at the deepend. I have a series of assignments to complete for my programming course, and part of one of them is to work out this following:
    d = (square root of) x2 + y2 + z2
    d,x,y and z are are all vriables that ive sorted out earlier. and x2 means x to the power of 2.
    if anyone could give me some pointers on the best way to do this that would be great
    thanks in advance
    glenn

    pointers:
    use java's Math lib.
    also, usually if x is raised to the power of y, people write x ^ y.
    double d = Math.sqrt(16);
    d is 4

  • Square root approximations and loops, output not as expected

    Hi guys,
    I'm trying to create a program that uses loops to guess the approximate value of a square root of an inputted value within an epsilon value. The program will guess with a value x, then use (x + (value/x))/2 to guess a closer value, where value = sqrt(input).
    Here is my solution class:
    public class RootApproximator
       public RootApproximator(double val, double eps)
              value = val;
              square = Math.sqrt(val);
              epsilon = eps;
              lower = square - epsilon;
       public double nextGuess()
              for (double i = 1; i < lower; i++)
                   i = (i + (value/i)) / 2;
                   guess = i;
              return guess;
       public boolean hasMoreGuesses()
              return (square - guess <= epsilon);
       private double square;
       private double value;
       private double epsilon;
       private double guess;
       private double lower;
    And here is my tester:
    public class RootApproximatorTester
       public static void main(String[] args)
          double a = 100;
          double epsilon = 1;
          RootApproximator approx = new RootApproximator(a, epsilon);
          System.out.println(approx.nextGuess());
          System.out.println("Expected: 1");
          System.out.println(approx.nextGuess());
          System.out.println("Expected: 50.5");
          while (approx.hasMoreGuesses())
             approx.nextGuess();
          System.out.println(Math.abs(approx.nextGuess() - 10) < epsilon);
          System.out.println("Expected: true");
    }Something is wrong with my loop, because the expected values are not appearing. Here is what the output looks like:
    50.5
    Expected: 1
    50.5
    Expected: 1
    ... // there should be more here, it should print:
    // true
    // Expected: true
    If anyone could please point out my errors so I can finish this program I would certainly appreciate it. Thank you all.

    I've modified your code a bit.
    class RootApproximator
         private double value;
         private double accuracy;
         private double firstGuess;
         public RootApproximator(double val)
              value = val;
              accuracy = 1;
         public double makeGuess()
              double guess = firstGuess;
              for (double i = 1; i <= accuracy; i++)
                   double temp = value / guess;
                   guess = (guess + temp) / 2.0;
                   System.out.println("Next Guess: "+guess);
              return guess;
         public void setFirstGuess(double num)
              firstGuess = num;
         //the higher the accuracy, the closer the square root will be
         public void setAccuracy(int num)
              accuracy = num;
    public class Test
         public static void main(String[] args)
              System.out.println("Number to take square root of:");
              java.util.Scanner input = new java.util.Scanner(System.in);
              double num = input.nextDouble();
              System.out.println("Number of times to iterate:");
              int acc = input.nextInt();
              System.out.println("First Guess:");
              double guess = input.nextDouble();
              RootApproximator approx = new RootApproximator(num);
              approx.setAccuracy(acc);
              approx.setFirstGuess(guess);
              double sqrt = approx.makeGuess();
              System.out.println("--------------------");
              System.out.println("Final Guess: "+sqrt);
              System.out.println("Actual Square Root: "+Math.sqrt(num));
    }

  • Is there a way to not include zero values in sums and an average?

    I'm working on a new performace evaluation & would like to sum the score of each line, then get an average of the total scores.
    example:  stength (1 value), Solid Performer (2 value), Performer (3 value), Recommend Development (4 value), N/A (zero value)  then a total score of all the values, not including the zero value. 
    Then an average score of all the scores given.
    Hope this makes sense! 
    Thanks in advance for the input!!!

    If you use the calculation option "The field is the ____ of the following fields:", nulll values and zero values are included as zero and the number of number of items use is the number of fields selected.
    If you want a different calculation, then you will have to write a custom script to sum and count the fields you want to include in the calculation.

  • OBIEE report to calculate avg daily demand by month and product line

    Hello,
    I have a requirement to calculate the average daily demand by month for each product line.
    Each Manufacturing Org has the list of working days for the month.
    Mfg Org
    Month
    Working days
    M1
    Jan-14
    23
    M1
    Feb-14
    20
    M1
    Mar-14
    21
    M2
    Jan-14
    20
    M2
    Feb-14
    20
    M2
    Mar-14
    20
    The data for demand in fact table is by day, Item, Org, Dem Qty
    Item rolls into Product Line
    Based on when the MRP plan was run the number of working days for the month reduces.
    So for eg if the MRP plan was run on 15 Jan then the number of working days reduced to 13 days.
    Then the average demand for Jan will be all demand in Janurary/ # of working days left in January ie 13
    The the average demand for Feb will be all demand in February/# of working days in February.
    So how can I dynamically calculate the average daily demand by Org and product line based on when MRP plan completion date
    Any pointer highly appreciated
    Thank you

    What else you need?
    looks like you got #working days for the month, use that metric as of jan 15th

  • Hi, my current plans and products include Creative Cloud Photography plan (one-year) and Creative Cloud single-app membership for Photoshop (one-year), I only use photoshop occasionally and for very basic things, are these two plans required for basic p

    Hi, my current plans and products include Creative Cloud Photography plan (one-year) and Creative Cloud single-app membership for Photoshop (one-year), I only use photoshop occasionally and for very basic things, are these two plans required for basic photoshop use or am I able to go with one or the other ?

    PS is part of the photography plan, so your single app plan is redundant.
    Mylenium

  • How to break a number into pieces and get the sum or product of the numbers

    on 10.2 I tried to use regular expression but TO_NUMBER function does not work with REGEXP_REPLACE as below;
    SQL> SELECT regexp_replace(123456,
      2                        '(.)',
      3                        '\1+') || '0' RESULT
      4    FROM dual;
    RESULT
    1+2+3+4+5+6+0
    SQL> SELECT 1+2+3+4+5+6+0 RESULT FROM dual;
        RESULT
            21
    SQL> SELECT regexp_replace(123456,
      2                        '(.)',
      3                        '\1*') || '1' RESULT
      4    FROM dual;
    RESULT
    1*2*3*4*5*6*1
    SQL> SELECT 1*2*3*4*5*6*1 RESULT FROM dual;
        RESULT
           720I recieve ORA-01722: invalid number as below;
    SQL> SELECT to_number(regexp_replace(123456,
      2                        '(.)',
      3                        '\1+') || '0') RESULT
      4    FROM dual;
    SELECT to_number(regexp_replace(123456,
                          '\1+') || '0') RESULT
      FROM dual
    ORA-01722: invalid numberAny comments? Thank you.

    On 11g you can use this:
    SQL>  select level
      2        , regexp_replace(level,'(.)','\1+') || '0' sum
      3        , xmlquery(regexp_replace(level,'(.)','\1+') || '0' returning content).getNumberVal() sum_evaluated
      4        , regexp_replace(level,'(.)','\1*') || '1' product
      5        , xmlquery(regexp_replace(level,'(.)','\1*') || '1' returning content).getNumberVal() product_evaluated
      6     from dual
      7  connect by level <= 100
      8  /
    LEVEL SUM                  SUM_EVALUATED PRODUCT              PRODUCT_EVALUATED
         1 1+0                              1 1*1                                  1
         2 2+0                              2 2*1                                  2
         3 3+0                              3 3*1                                  3
         4 4+0                              4 4*1                                  4
         5 5+0                              5 5*1                                  5
         6 6+0                              6 6*1                                  6
         7 7+0                              7 7*1                                  7
         8 8+0                              8 8*1                                  8
         9 9+0                              9 9*1                                  9
        10 1+0+0                            1 1*0*1                                0
        11 1+1+0                            2 1*1*1                                1
        12 1+2+0                            3 1*2*1                                2
        13 1+3+0                            4 1*3*1                                3
        14 1+4+0                            5 1*4*1                                4
        15 1+5+0                            6 1*5*1                                5
        16 1+6+0                            7 1*6*1                                6
        17 1+7+0                            8 1*7*1                                7
        18 1+8+0                            9 1*8*1                                8
        19 1+9+0                           10 1*9*1                                9
        20 2+0+0                            2 2*0*1                                0
        21 2+1+0                            3 2*1*1                                2
        22 2+2+0                            4 2*2*1                                4
        23 2+3+0                            5 2*3*1                                6
        24 2+4+0                            6 2*4*1                                8
        25 2+5+0                            7 2*5*1                               10
        26 2+6+0                            8 2*6*1                               12
        27 2+7+0                            9 2*7*1                               14
        28 2+8+0                           10 2*8*1                               16
        29 2+9+0                           11 2*9*1                               18
        30 3+0+0                            3 3*0*1                                0
        31 3+1+0                            4 3*1*1                                3
        32 3+2+0                            5 3*2*1                                6
        33 3+3+0                            6 3*3*1                                9
        34 3+4+0                            7 3*4*1                               12
        35 3+5+0                            8 3*5*1                               15
        36 3+6+0                            9 3*6*1                               18
        37 3+7+0                           10 3*7*1                               21
        38 3+8+0                           11 3*8*1                               24
        39 3+9+0                           12 3*9*1                               27
        40 4+0+0                            4 4*0*1                                0
        41 4+1+0                            5 4*1*1                                4
        42 4+2+0                            6 4*2*1                                8
        43 4+3+0                            7 4*3*1                               12
        44 4+4+0                            8 4*4*1                               16
        45 4+5+0                            9 4*5*1                               20
        46 4+6+0                           10 4*6*1                               24
        47 4+7+0                           11 4*7*1                               28
        48 4+8+0                           12 4*8*1                               32
        49 4+9+0                           13 4*9*1                               36
        50 5+0+0                            5 5*0*1                                0
        51 5+1+0                            6 5*1*1                                5
        52 5+2+0                            7 5*2*1                               10
        53 5+3+0                            8 5*3*1                               15
        54 5+4+0                            9 5*4*1                               20
        55 5+5+0                           10 5*5*1                               25
        56 5+6+0                           11 5*6*1                               30
        57 5+7+0                           12 5*7*1                               35
        58 5+8+0                           13 5*8*1                               40
        59 5+9+0                           14 5*9*1                               45
        60 6+0+0                            6 6*0*1                                0
        61 6+1+0                            7 6*1*1                                6
        62 6+2+0                            8 6*2*1                               12
        63 6+3+0                            9 6*3*1                               18
        64 6+4+0                           10 6*4*1                               24
        65 6+5+0                           11 6*5*1                               30
        66 6+6+0                           12 6*6*1                               36
        67 6+7+0                           13 6*7*1                               42
        68 6+8+0                           14 6*8*1                               48
        69 6+9+0                           15 6*9*1                               54
        70 7+0+0                            7 7*0*1                                0
        71 7+1+0                            8 7*1*1                                7
        72 7+2+0                            9 7*2*1                               14
        73 7+3+0                           10 7*3*1                               21
        74 7+4+0                           11 7*4*1                               28
        75 7+5+0                           12 7*5*1                               35
        76 7+6+0                           13 7*6*1                               42
        77 7+7+0                           14 7*7*1                               49
        78 7+8+0                           15 7*8*1                               56
        79 7+9+0                           16 7*9*1                               63
        80 8+0+0                            8 8*0*1                                0
        81 8+1+0                            9 8*1*1                                8
        82 8+2+0                           10 8*2*1                               16
        83 8+3+0                           11 8*3*1                               24
        84 8+4+0                           12 8*4*1                               32
        85 8+5+0                           13 8*5*1                               40
        86 8+6+0                           14 8*6*1                               48
        87 8+7+0                           15 8*7*1                               56
        88 8+8+0                           16 8*8*1                               64
        89 8+9+0                           17 8*9*1                               72
        90 9+0+0                            9 9*0*1                                0
        91 9+1+0                           10 9*1*1                                9
        92 9+2+0                           11 9*2*1                               18
        93 9+3+0                           12 9*3*1                               27
        94 9+4+0                           13 9*4*1                               36
        95 9+5+0                           14 9*5*1                               45
        96 9+6+0                           15 9*6*1                               54
        97 9+7+0                           16 9*7*1                               63
        98 9+8+0                           17 9*8*1                               72
        99 9+9+0                           18 9*9*1                               81
       100 1+0+0+0                          1 1*0*0*1                              0
    100 rijen zijn geselecteerd.which doesn't work on 10.2 unfortunately. And I'm not aware of any other method to do a dynamic evaluation in SQL in that version.
    Regards,
    Rob.

  • How to find square root, log recursively???

    I need to find the square root of a number entered recursively and log as well. Your help would be greatly appreciated. Thanks in advance!
    import java.io.*;
    /**Class provides recursive versions
    * of simple arithmetic operations.
    public class Ops2
         private static BufferedReader in = null;
         /**successor, return n + 1*/
         public static int suc(int n)
              return n + 1;
         /**predecessor, return n - 1*/
         public static int pre(int n)
              if (n == 0)
                   return 0;
              else
                   return n - 1;
         /**add two numbers entered*/
         public static int add(int n, int m)
              if (m == 0)
                   return n;
              else
                   return suc(add(n, pre(m)));
         /**subtract two numbers entered*/
         public static int sub(int n, int m)
              if (n < m)
                   return 0;
              else if (m == 0)
                   return n;
              else
                   return pre(sub(n, pre(m)));
         /**multiply two numbers entered*/
         public static int mult(int n, int m)
              if (m == 0)
                   return 0;
              else
                   return add(mult(n, pre(m)), n);
         /**divide two numbers entered*/
         public static int div(int n, int m)
              if (n < m)
                   return 0;
              else
                   return suc(div(sub(n, m), m));
         /**raise first number to second number*/
         public static int exp(int n, int m)
              if (m == 0)
                   return 1;
              else
                   return mult(exp(n, pre(m)), n);
         /**log of number entered*/
         public static int log(int n)
              if (n < 2)
                   return 0;
              else
                   return suc(log(div(n, 2)));
         /**square root of number entered*/
         public static int sqrt(int n)
              if (n == 0)
                   return 0;
              else
                   return sqrt(div(n, ));
         /**remainder of first number entered divided by second number*/
         public static int mod(int n, int m)
              if (n < m)
                   return 0;
              else
                   return mod(div(n, pre(m)), m);
         public static void prt(String s)
              System.out.print(s);
         public static void prtln(String s)
              System.out.println(s);
         public static void main(String [ ] args)
              prtln("Welcome to the amazing calculator");
              prtln("It can add, multiply and do powers for");
              prtln("naturals (including 0). Note that all the");
              prtln("HARDWARE does is add 1 or substract 1 to any number!!");
              in = new BufferedReader(new InputStreamReader ( System.in ) );
              int It;
              while ( (It = getOp()) >= 0)
                   prt("" + It + "\n");
            private static int getOp( )
            int first, second;
            String op;
            try
                System.out.println( "Enter operation:" );
                do
                    op = in.readLine( );
                } while( op.length( ) == 0 );
             System.out.println( "Enter first number: " );
                first = Integer.parseInt( in.readLine( ) );
                System.out.println( "Enter second number: " );
                second = Integer.parseInt( in.readLine( ) );
             prtln("");
             prt(first + " " + op + " " + second + " = ");
                switch( op.charAt( 0 ) )
                  case '+':
                    return add(first, second);
                  case '-':
                       return sub(first, second);
                  case '*':
                    return mult(first, second);
                  case '/':
                       return div(first, second);
                  case '^':
                    return exp(first, second);
                  case 'v':
                       return log(first);
                  case 'q':
                       return sqrt(first);
                  case '%':
                       return mod(first, second);
                  case 's':
                       return suc(first);
                  case 'p':
                       return pre(first);
                  default:
                    System.err.println( "Need +, *, or ^" );
                    return -1;
            catch( IOException e )
                System.err.println( e );
                return  0;
    }

    Hi,
    Is there any one to make a program for me in Turbo
    C++ for Dos, which can calculate the square root of
    any number without using the sqrt( ) or any ready
    made functions.
    The program should calculate the s.root of the number
    by a formula or procedure defined by the user
    (programmer).
    Thanks.This is a Java forum!
    If you want Java help:
    1. Start your own thread.
    2. Use code tags (above posting box) if you post code.
    3. No one will write the program for you. We will help by answering your questions and giving advice on how to fix problems in code you wrote.
    4. The formula you need to implement is given above by dizzy.

  • Fast Inverse Square Root

    I expect no replies to this thread - because there are no
    answers, but I want to raise awareness of a faculty of other
    languages that is missing in Flash that would really help 3D and
    games to be built in Flash.
    Below is an optimisation of the Quake 3 inverse square root
    hack. What does it do? Well in games and 3D we use a lot of vector
    math and that involves calculating normals. To calculate a normal
    you divide a vector's parameters by it's length, the length you
    obtain by pythagoras theorem. But of course division is slow - if
    only there was a way we could get 1.0/Math.sqrt so we could just
    multiply the vector and speed it up.
    Which is what the code below does in Java / Processing. It
    runs at the same speed as Math.sqrt, but for not having to divide,
    that's still a massive speed increase.
    But we can't do this in Flash because there isn't a way to
    convert a Number/float into its integer-bits representation. Please
    could everyone whinge at Adobe about this and give us access to a
    very powerful tool. Even the guys working on Papervision are having
    trouble with this issue.

    that's just an implementation of newton's method for finding
    the zeros of a differentiable function. for a given x whose inverse
    sq rt you want to find, the function is:
    f(y) = 1/(y*y) - x;
    1. you can find the positive zero of f using newton's method.
    2. you only need to consider values of x between 1 and 10
    because you can rewrite x = 10^^E * m, where 1<=m<10.
    3. the inverseRt(x) = 10^^(-E/2) * inverseRt(m)
    4. you don't have to divide E by 2. you can use bitwise shift
    to the right by 1.
    5. you don't have to multiply 10^^(-E/2) by inverseRt(m): you
    can use a decimal shift of inverseRt(m);
    6. your left to find the positive zero of f(y) = 1/(y*y) - m,
    1<=m<10.
    and at this point i realized what, i believe, is a much
    faster way to find inverse roots: use a look-up table.
    you only need a table of inverse roots for numbers m,
    1<m<=10.
    for a given x = 10^^E*m = 10^^(e/2) *10^^(E-e/2)*m, where e
    is the largest even integer less than or equal to E (if E is
    positive, e is the greatest even integer less than or equal to E,
    if E is negative), you need to look-up, at most, two inverse roots,
    perform one multiplication and one decimal shift:
    inverseRt(x) = 10^^(-e) * inverseRt(10) *inverseRt(m), if
    E-e/2 = 1 and
    inverseRt(x) = 10^^(-e) * inverseRt(m), if E-e/2 = 0.

  • Problems with square root approximations with loops program

    i'm having some trouble with this program, this loop stuff is confusing me and i know i'm not doing this correctly at all. the expected values in the tester are not matching up with the output. i have tried many variations of the loop in this code even modifying the i parameter in the loop which i guess is considered bad form. nothing seems to work...
    here is what i have for my solution class:
    /** A class that takes the inputted number by the tester and squares it, and
    *  loops guesses when the nextGuess() method is called. The epsilon value is
    *  also inputted by the user, and when the most recent guess returns a value
    *  <= epsilon, then the hasMoreGuesses() method should return false.
    public class RootApproximator
       /** Takes the inputted values from the tester to construct a RootApproximator.
        * @param val the value of the number to be squared and guessed.
        * @param eps the gap in which the approximation is considered acceptable.
         public RootApproximator(double val, double eps)
              value = val;
              square = Math.sqrt(val);
              epsilon = eps;
       /** Uses the algorithm where 1 is the first initial guess of the
        *  square root of the inputted value. The algorithm is defined by
        *  "If X is a guess for a square root of a number, then the average
        *  of X and value/X is a closer approximation.
        *  @return increasingly closer guesses as the method is continually used.
       public double nextGuess()
             final int TRIES = 10000;
             double guess = 1;
              for (double i = 1; i < TRIES; i++)
                   double temp = value / guess;
                   guess = (guess + temp) / 2.0;
              return guess;
       /** Determines if there are more guesses left if the difference
        *  of the square and current guess are not equal to or less than
        *  epsilon.
        *  @return the value of the condition.
       public boolean hasMoreGuesses()
              return (square - guess <= epsilon);
       private double square;
       private double value;
       private double epsilon;
       private double guess;
    here is the tester:
    public class RootApproximatorTester
       public static void main(String[] args)
          double a = 100;
          double epsilon = 1;
          RootApproximator approx = new RootApproximator(a, epsilon);
          System.out.println(approx.nextGuess());
          System.out.println("Expected: 1");
          System.out.println(approx.nextGuess());
          System.out.println("Expected: 50.5");
          while (approx.hasMoreGuesses())
             approx.nextGuess();
          System.out.println(Math.abs(approx.nextGuess() - 10) < epsilon);
          System.out.println("Expected: true");
    and here is the output:
    10.0
    Expected: 1 // not sure why this should be 1, perhaps because it is the first guess.
    10.0
    Expected: 50.5 // (100 + 1) / 2, average of the inputted value and the first guess.
    true
    Expected: true
    i'm new to java this is my first java course and this stuff is frustrating. i'm really clueless as to what to do next, if anyone could please give me some helpful advice i would really appreciate it. thank you all.

    i'm new to java this is my first java course and this
    stuff is frustrating. i'm really clueless as to what
    to do nextMaybe it's because you don't have a strategy for what the program is supposed to do? To me it looks like a numerical scheme for finding the squareroot of a number.
    Say the number you want to squarerroot is called value and that you have an approximation called guess. How do you determine whether guess is good enought?
    Well in hasMoreGuesses you check whether,
    (abs(value-guess*guess) < epsilon)
    The above decides if guess is within epsilon of being the squareroot of value.
    When you calculate the next guess in nextGuess why do you loop so many times? Aren't you supposed to make just one new guess like,
    guess = (guess + value/guess)/2.0
    The above generates a new guess based on the fact that guess and value/guess must be on each side of value so that the average of them must be closer too value.
    Now you can put the two together to a complete algoritm like,
    while (hasMoreGuesses()) {
       nextGuess();
    }In each iteration of the loop a new "guess" of the squareroot is generated and this continues until the guess is a sufficiently close approximation of the squareroot.

  • Alternate square root method

    Besides using the math class, may I know if there is another way to find the square root of an integer?
    thank you.

    Besides using the math class, may I know if there is
    another way to find the square root of an integer? There are several numerical methods available. The most common is built on Newton-Raphson.
    The idea is very simple. Say you want to calculate the squareroot of N. One can note that this squareroot will be somewhere between N and 1/N. So an approximate value will be in the middle like
    N1 = (N + 1/N)/2.
    Now you're closer and can get even closer by repeating this again with
    N2 = (N1 + 1/N1)/2.
    This is repeated again and again until Nx*Nx (where x are the numbers 1,2,3,4,5,6 etcetera) is sufficiently close to N. When it is Nx is the squareroot of N.

Maybe you are looking for