-4

I have 2 function, but for the same input a=5 und b=6 different values -.- why?

f1:

wolframalpha.com/input/?i=%28%285^3%2B6^3%29%285^3-6^3%29%29^3%2B3%28%285%286^2%29%2B%285^2%296%29%285%286^2%29-%286^2%296%29%29+%3D

f2:

wolframalpha.com/input/?i=%285^2-6^2%29^3

my haskell code:

f :: Double -> Double -> Double
f a b = (((a**3)+(b**3))*((a**3)-(b**3)))+3*((a*(b**2) + (a**2)*a)*(a*(b**2) - (a**2)*a))

h :: Double -> Double -> Double
h a b = ((a+b)*(a-b))**3

f--> wolframalpha.com/input/?i=%28%28a^3%2Bb^3%29%28a^3-b^3%29%29^3%2B3%28%28a%28b^2%29%2B%28a^2%29b%29%28a%28b^2%29-%28a^2%29b%29%29

h--> wolframalpha.com/input/?i=%28a^2-b^2%29^3

harpo
  • 41,820
  • 13
  • 96
  • 131
corium
  • 53
  • 4
  • What output were you expecting, and what did you get. Typically we don't actually run your code, we just look at it and predict what is going on, so it helps if you show us output. – luqui May 05 '11 at 05:08
  • Main> h 6 5 output => 1331.0 Main> f 6 5 output=> -41436.9999999999 – corium May 05 '11 at 05:25
  • f :: Double -> Double -> Double f a b = ((a**3+b**3)*(a**3-b**3)) + 3*((a*b**2 + a**2*b)*(a*b**2 - a**2*b)) it works =) nice – corium May 05 '11 at 06:19
  • Next time be sure to use TEXT for your links and make a proper hyperref. I have no idea what you're expecting me to get from the links. Also, the plots show fairly clearly that these functions are not the same - not sure what made you think they are. – Thomas M. DuBuisson May 05 '11 at 17:49

1 Answers1

4

Your functions aren't equivalent. Expand each out, and for example the a**6 terms are different.

Ganesh Sittampalam
  • 28,821
  • 4
  • 79
  • 98