Skip to content
Advertisement

Tag: math

Why is my trapezoid rule implementation not producing expected results?

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

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

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

Advertisement