I have implemented a function to find the trapezoid rule of a given function, the function produces poor results for . When I try to calculate the trapezoid rule with n < 8 it produces a value much larger than the actual area, which is unexpected, I have graphed f(x) and drawn how I believe the first few numbers of
Tag: math
Looking to get the yearly returns on this total compound interest calculator
I’m really new to Java so please excuse if this isn’t the 100% right way to even write this code. So I’ve been messing around with this code for about 6 hours now, and I can not for the life of me figure out how to fix this issue: I have a compound interest calculator that takes user input for
Trying to create a calculator for Newton’s Square Root without using built-in things for school. I have it down but the math is a little off
I will be able to accept an answer in 6 minutes. For now going to state that my answer has successfully been solved by Elliott Frisch. He provided a solution to fix the problem I ran into. When attempting to do the “Equation” it correctly performs the action but seems to be off. Off being that it doesn’t really display
Bezier curve : forcing a curve of 4 points to pass through control points in 3D space
I have read the thread to make this happen for 4 points but only in 2D space here . I have implemented the answer for 3D but only for 3 control points here I have read this post but don’t understand the sudo code or the math Can anyone simplify in java? I don’t want to draw the curve as
How to calculate the coordinates of the second point on the map?
Example pictureI have the coordinates of the first point on the map, there is a distance between the points and there are degrees of rotation relative to the cardinal points (from the compass). Please tell me how to calculate the coordinates of the second point on the map? I tried to take the formula for finding the distance between points
Rounding in Java using Math.random()
Suppose I write then one would obtain and output of x in [0, 4.9…]. But upon casting it as an integer, the result I continuously see (in my course) is [0, 4]. My question is how we are defining the rounding function; I am familiar with the floor function, and the floor of 4.9… is precisely 5 due to there
(Java) Generating random number for division program
Hi I’m new to programming and I’m trying to make a division program that can generate 2 random numbers and the condition is that the first number must be more than the second and they give no remainder. If the number generated does not meet the condition it keeps generating until the conditions are met. Can anyone help me fix
Math function to get output desired
I am currently learning the basic math functions and I am struggling to get this output for my homework. I think the wording is just making me more and more confused. Thanks in advance for your help! Here is the problem layout: Z = 7 Use the Math methods and the System.out.println statement to display: the square root of z
Karatsuba Algorithm without BigInteger in Java, unexpected behaviour while recursion
So I want to run Karatsuba Algorithm without using class BigInteger in Java, so upon following the pseudo-code and this question, I came with the following code Now, the problem with this is that it’s producing the wrong answer, 1234*5678 is giving 11686652, which should’ve been 7006652. As a beginner to Java and algorithms, I am unable to pinpoint the
decimal value of the number formed by concatenating the binary representations of first n natural numbers
Given a number n, find the decimal value of the number formed by concatenating the binary representations of first n natural numbers. Print answer modulo 10^9+7. Also, n can be as big as 10^9 and hence logarithmic time approach is needed. Eg: n=4, Answer = 220 Explanation: Number formed=11011100 (1=1,2=10,3=11,4=100). Decimal value of 11011100=”220″. The code I am using below