I understand that y = n ^ 4 will be pow(n,4)...but what about drawing the curve
y = 1 - x ^ 4
y = (1 - x) ^ 4
y = 1-(1 - x) ^ 4

I appreciate your help. Thanks.

Recommended Answers

All 14 Replies

What's the problem here? Are you having trouble building the expressions to get these values?

y = 1-(pow(x, 4));

etc...

Here's the code i have:

for (int x = 0; x < 100; x++) {
float n = norm(x, 0.0, 100.0);
float y = pow(1-n, 4); // this is supposed to represent y = 1 - x ^ 4
y *= 100;
smooth();
point(x, y);
}

Can you explain your problem?
For example show the program's output and explain what's wrong and what you want it to be.

see attachment for output...
points begin at (100,0)
they should begin at (0,100) and ascend to (100,0)

Show the program's output and explain what's wrong with it.
I assume that the image you posted is the desired output.

no the image I posted is not the desired output...it's what is being output, but it's not correct. I have drawn what the curve output is supposed to be in illustrator so you can see what I'm struggling with. I believe it's just the way I'm writing the parameters that's the problem.

Can you pick an x value on the curve and show what the y value should be and what is being generated in your code? Then look at the methods and equations you are using and figure out why.

There are several methods in your code that I am not familiar with: norm, smooth and point.
Are these necessary to demonstrate the problem?
Can you generate a two column output with x in col1 and y in col2?

since this is normalized from 0.0 to 1.0 in both dimensions, the x value would be 0.6, and the y value would be 0.9

norm is basically taking a number say 102.0 and assigning a low value and high value to now plot between 0.0 and 1.0
norm(value, low, high)
e.g.
norm(102.0, 0.0, 255.0) // basically turns out to be 0.4 because 102.0/255.0
smooth() // makes the points as vector instead of pixels
point(x,y) // where x and y lie in for example if the size of the
// window is 100,100 pixels and you have point(50,50) it would
// in the middle of window

Member Avatar for coil

float y = pow(1-n, 4); actually represents (1-x)^4.

I assume that's not what you want. If you want 1-(x^4), do this: float y=1-pow(n, 4)

float y = pow(1-n, 4); // this is supposed to represent y = 1 - x ^ 4

This represents (1-n)^4, not 1- (n^4)

In the expression you're trying to create, 1 - x^4, which operation takes place first? The subtraction, or the raising to the fourth power?

float y = pow(1-n, 4); actually represents (1-x)^4.

I assume that's not what you want. If you want 1-(x^4), do this: float y=1-pow(n, 4)

Thanks it worked!
but i don't understand why it worked...can you explain?

my thinking is that it basically says n to the 4th power, and then 1 minus the exponential return in the parentheses.

Member Avatar for coil

Great! The method Math.pow(x, y) raises x to the power of y. So when you did pow(1-x, 4), you raised (1-x) to the power of 4. However, 1-pow(x, 4) raises x to the power of 4, then it subtracts it from 1.

Hope that makes sense

Great! The method Math.pow(x, y) raises x to the power of y. So when you did pow(1-x, 4), you raised (1-x) to the power of 4. However, 1-pow(x, 4) raises x to the power of 4, then it subtracts it from 1.

Hope that makes sense

Yeah...makes sense
i'm new to programming, trying to learn processing first then jump to java and then python, then maybe C++

But for now, I struggle with the basics...i have such a long way to go.
i'm more interested in programming visuals and design...starting a program at parsons design and technology in NYC. I am trying to get up to speed before I start. I will have more problems in the future:S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.