Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to estimate pi by the series using the Newton-Raphson sequence t

ID: 3872061 • Letter: W

Question

Write a program to estimate pi by the series using the
Newton-Raphson sequence to calculate the square root factor in jasmin code. SO a .jfile not a .java file thank you

modify the code below it is the slow conversion of PI I need the Newton Raphson version

.class public Pi
.super java/lang/Object

; standard initializer
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method

.method public static main([Ljava/lang/String;)V
; set limits used by this method
.limit locals 16
.limit stack 8

; setup local variables:

; 1 - the PrintStream object held in java.lang.System.out
getstatic java/lang/System/out Ljava/io/PrintStream;
astore_1

; 2 - the counter used in the loop
ldc 1000000          ; loop counter
istore_2           
ldc2_w 4.0           ; push double number -4
dstore 4           
dconst_1
dstore 6             ; denominator
ldc2_w 4.0
dstore 8             ; numerator

Loop:

dload 4
dload 8
dload 6            
ldc2_w 2.0
dadd
dup2
dstore 6              ;denominator 2
ddiv
dsub
dload 8
dneg
dstore 8             ;numerator 2
dstore 4             ; sum 2
dload 4
invokestatic java/lang/String/valueOf(D)Ljava/lang/String;
astore_3

; decrement the counter and loop
iinc 2 -1
iload_2

ifne Loop

; print result
aload_1 ; push the PrintStream object
aload_3 ; push the string we just created - then ...
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V

; done
return

.end method

Explanation / Answer

FastestPIest.j

; Generated by ClassFileAnalyzer (Can)
; Analyzer and Disassembler for Java class files
; (Jasmin syntax 2, http://jasmin.sourceforge.net)
;
; ClassFileAnalyzer, version 0.7.0


.bytecode 52.0
.source FastestPIest.java
.class public chegg/FastestPIest
.super java/lang/Object

.method public <init>()V
.limit stack 1
.limit locals 1
.var 0 is this Lchegg/FastestPIest; from Label0 to Label4
Label0:
.line 3
0: aload_0
1: invokespecial java/lang/Object/<init>()V
Label4:
4: return
.end method

.method public static main([Ljava/lang/String;)V
.limit stack 8
.limit locals 12
.var 0 is args [Ljava/lang/String; from Label0 to Label106
.var 1 is pi D from Label2 to Label106
.var 11 is i I from Label68 to Label94
.var 3 is numerator D from Label4 to Label106
.var 5 is denominator D from Label7 to Label106
.var 7 is k I from Label10 to Label55
.var 7 is s D from Label60 to Label106
.var 9 is sqrt_s D from Label65 to Label106
Label0:
.line 6
0: dconst_1
1: dstore_1
Label2:
2: dconst_1
3: dstore_3
Label4:
4: dconst_1
5: dstore 5
Label7:
.line 8
7: iconst_1
8: istore 7
Label10:
10: goto Label48
Label13:
.line 9
13: dload_3
14: iload 7
16: i2d
17: dmul
18: dstore_3
.line 10
19: dload 5
21: iconst_2
22: iload 7
24: imul
25: iconst_2
26: iload 7
28: imul
29: iconst_1
30: iadd
31: imul
32: i2d
33: dmul
34: dstore 5
.line 11
36: dload_1
37: dload_3
38: dload_3
39: dmul
40: dload 5
42: ddiv
43: dadd
44: dstore_1
.line 8
45: iinc 7 1
Label48:
48: iload 7
50: bipush 25
52: if_icmplt Label13
Label55:
.line 14
55: ldc2_w 6.75
58: dstore 7
Label60:
60: ldc2_w 2.0
63: dstore 9
Label65:
.line 15
65: iconst_0
66: istore 11
Label68:
68: goto Label88
Label71:
.line 16
71: ldc2_w 0.5
74: dload 9
76: dload 7
78: dload 9
80: ddiv
81: dadd
82: dmul
83: dstore 9
.line 15
85: iinc 11 1
Label88:
88: iload 11
90: iconst_5
91: if_icmplt Label71
Label94:
.line 19
94: dload_1
95: dload 9
97: dmul
98: dstore_1
.line 20
99: getstatic java/lang/System/out Ljava/io/PrintStream;
102: dload_1
103: invokevirtual java/io/PrintStream/println(D)V
Label106:
.line 21
106: return
; full_frame (frameNumber = 0)
; frame_type = 255, offset_delta = 13
; frame bytes: 255 0 13 0 5 7 0 46 3 3 3 1 0 0
.stack
offset 13
locals Object [Ljava/lang/String;
locals Double
locals Double
locals Double
locals Integer
.end stack
; same_frame (frameNumber = 1)
; frame_type = 34, offset_delta = 34
; frame bytes: 34
.stack
offset 48
locals Object [Ljava/lang/String;
locals Double
locals Double
locals Double
locals Integer
.end stack
; full_frame (frameNumber = 2)
; frame_type = 255, offset_delta = 22
; frame bytes: 255 0 22 0 7 7 0 46 3 3 3 3 3 1 0 0
.stack
offset 71
locals Object [Ljava/lang/String;
locals Double
locals Double
locals Double
locals Double
locals Double
locals Integer
.end stack
; same_frame (frameNumber = 3)
; frame_type = 16, offset_delta = 16
; frame bytes: 16
.stack
offset 88
locals Object [Ljava/lang/String;
locals Double
locals Double
locals Double
locals Double
locals Double
locals Integer
.end stack
.end method

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote