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?

# Scheme -- Sqrt not working

Page 1 of 1## 2 Replies - 2697 Views - Last Post: 18 May 2008 - 02:09 AM

##
**Replies To:** Scheme -- Sqrt not working

### #2

## 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

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

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

(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

### #3

## Re: Scheme -- Sqrt not working

Posted 18 May 2008 - 02:09 AM

fluxion, 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

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

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

(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!

Page 1 of 1