# Math power Function in Flash 8

**URL:** <https://forum.kirupa.com/t/math-power-function-in-flash-8/184933>\
**Category:** flash\
**Created:** [April 9, 2006, 12:43pm UTC](https://forum.kirupa.com/t/math-power-function-in-flash-8/184933 "2006-04-09T12:43:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bachchun](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@bachchun](https://forum.kirupa.com/u/bachchun)\
**Post date:** [April 9, 2006, 12:43pm UTC](https://forum.kirupa.com/t/math-power-function-in-flash-8/184933/1 "2006-04-09T12:43:37Z")

</div>

How can I make Flash calculate the value of the function y= (1 - x^2)^3 where x is the user input value?

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 9, 2006, 5:00pm UTC](https://forum.kirupa.com/t/math-power-function-in-flash-8/184933/2 "2006-04-09T17:00:03Z")

</div>

```auto
function calculate(x:Number):Number {
    return Math.pow(Math.pow(1-x, 2), 3);
}
var value:Number = calculate(5);
trace(value);

```

---

<div class="post-metadata">

**Author:** ![MichaelxxOA](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@MichaelxxOA](https://forum.kirupa.com/u/MichaelxxOA)\
**Post date:** [April 10, 2006, 9:37am UTC](https://forum.kirupa.com/t/math-power-function-in-flash-8/184933/3 "2006-04-10T09:37:34Z")

</div>

I might just be tired, although I’m pretty sure that’s not it. But it appears that your calculation is wrong Matthew.

you have (1 - x)^2… it is 1 - x^2, the Exponent has more precedence than the subtraction operator

The code should be…

```auto

function calculate( x:Number ) : Number
{
   return Math.pow(( 1 - (x * x)), 3);
}
var value:Number = calculate(5);
trace( value );

```

Another thing to think about is, multiplying two values together is much faster than making a call to the Math classes pow method to do it. I usually just multiply the two values together rather than square the single value. It’s really just preference.

I am very tired… Catch you on the flip side

\_Michael

---

<div class="post-metadata">

**Author:** ![bachchun](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@bachchun](https://forum.kirupa.com/u/bachchun)\
**Post date:** [April 10, 2006, 10:19am UTC](https://forum.kirupa.com/t/math-power-function-in-flash-8/184933/4 "2006-04-10T10:19:08Z")

</div>

Why is there calculate (5)? I dont understand this. Is it necessary to declare variable x or can I just write ‘InputValue’ which is already declared as variable input text?
