# Thread: How to: Create a range of desired variables (two decimals) into an array

1. Member
Join Date
Jan 2013
Posts
5
Rep Power
0

## How to: Create a range of desired variables (two decimals) into an array

Hi everyone,

I'm curious how I can create a range of desired variables ranging from (-1.00 all the way to 1.00) @ 0.01 increments.

I will want to output this in table format as the first column. There will be 4 columns btw

1st column = the variable [two decimals btw -1.00 and 1.00]
2nd column = math.sin(x) of each
3rd column = my personal sin function
4th column = math.abs(difference between them)

Java Code:
```public class TaylorSin {
public static void main(String[] args) {
for (double lB = -100, lB <= 100,lB++) lB.log(x/100);
double[] x = lB;
double ActualFormula = math.sin(x);
double MyFormula = sin(x);
double Absolute = math.abs(ActualFormula - MyFormula);
System.out.format("%3d%10d%10d%4d", double x, ActualFormula, MyFormula, Absolute);```
I'm calling my other personally created sin(x) method and attemping to output in table format.

Let me know, because I'm very confused.
Last edited by mcgillstudent; 03-05-2013 at 08:47 PM.

2. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,838
Rep Power
10

## Re: How to: Create a range of desired variables (two decimals) into an array

Your for loop only has a single statement in it. And it doesn't do anything unless you are changing something in IB.log(). But even then, x is undefined.

To increment your value by .01 in your for loop just use IB = IB + .01 (or shorthand IB += .01)

Regards,
Jim

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•