# Scheme -- Sqrt not working

Page 1 of 1

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

### #1 shiningmer

• New D.I.C Head

Reputation: 0
• 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

• New D.I.C Head

Reputation: 1
• 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

(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

• New D.I.C Head

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

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

(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!
Was This Post Helpful? 0

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}