2 Replies - 2228 Views - Last Post: 18 May 2008 - 02:09 AM

#1 shiningmer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-May 08

Scheme -- Sqrt not working

Posted 10 May 2008 - 06:41 AM

Hey!

I'm having a little problem with a program I'm trying to write in Dr Scheme
I wrote
(define (vectornorm t n s)
(sqrt (+ (expt t 2) (expt n 2) (expt s 2)) 1/2))


But it gives error in the square root part. Can anyone help me?
Is This A Good Question/Topic? 0
  • +

Replies To: Scheme -- Sqrt not working

#2 fluxion  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 19-April 08

Re: Scheme -- Sqrt not working

Posted 17 May 2008 - 06:20 PM

im sure you've already figured this out by now, really simple mistake. but just in case: sqrt takes 1 argument. seems to me that you meant to do (expt value1 1/2) to do the sqrt for you.

the fix is obvious, but im gonna post this to see if the forum does syntax highlighting for scheme :P

(define (vectornorm t n s)
  (sqrt (+ (expt t 2) (expt n 2) (expt s 2)))


also, i dont know if you had completed the function yet, but your code seems to produce the magnitude rather than a normalized vector

This post has been edited by fluxion: 17 May 2008 - 06:21 PM

Was This Post Helpful? 0
  • +
  • -

#3 shiningmer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-May 08

Re: Scheme -- Sqrt not working

Posted 18 May 2008 - 02:09 AM

View Postfluxion, on 17 May, 2008 - 06:20 PM, said:

im sure you've already figured this out by now, really simple mistake. but just in case: sqrt takes 1 argument. seems to me that you meant to do (expt value1 1/2) to do the sqrt for you.

the fix is obvious, but im gonna post this to see if the forum does syntax highlighting for scheme :P

(define (vectornorm t n s)
  (sqrt (+ (expt t 2) (expt n 2) (expt s 2)))


also, i dont know if you had completed the function yet, but your code seems to produce the magnitude rather than a normalized vector


you're right. when i looked at it again i found my mistake immediately, but thanks anyway! :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1