Jump to content

Recommended Posts

Posted

Hello to all,

 

Attached below are three formulas to solve for distance for ellipsodial heads of different types.

My question is can each formula be written in one argument or does it need to be written in several?

I am not completely sure how to break this down. Any help on this would be greatly appreciated.

 

Again Thank You in advance,

The Buzzard

IDD2.jpg

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    10

  • alanjt

    9

  • Lee Mac

    4

  • fixo

    1

Popular Days

Top Posters In This Topic

Posted Images

Posted

Sorry,

 

I think I explained myself incorrectly.

What I meant was can each formula be written in one statement with the given arguments.

Posted
Sorry,

 

I think I explained myself incorrectly.

What I meant was can each formula be written in one statement with the given arguments.

Not sure about but have you tried use the COND statement?

 

~'J'~

Posted

I probably overlooked something, but this should be a good example (your first function)...

 

(defun foo (L r O D tt / _sq)
 (setq _sq (lambda (#) (* # #)))

 (- L (sqrt (- (_sq (- L r)) (_sq (/ (* O D) (apply '- (list 2 tt r)))))))
) ;_ defun

Posted

Sorry again,

 

Fixo,

 

I do not mean to combine all three or a way to pick a formula.

For each formula above can the supplied arguments be put into one continuous statement for each formula.

Posted

Thanks Alan,

 

I think I can figure the rest from here.

But what is apply in the statement for.

Posted
Thanks Alan,

 

I think I can figure the rest from here.

But what is apply in the statement for.

 

It was to subtract the 3 numbers, but I completely forgot you can add more than 2 numbers to the (- function.

 

(defun foo (L r O D tt / _sq)
 (setq _sq (lambda (#) (* # #)))

 (- L (sqrt (- (_sq (- L r)) (_sq (/ (* O D) (- 2 tt r))))))
) ;_ defun

Posted

You don't have to use the _sq sub function. However, it saves you a lot of typing and condenses your routine quite a bit.

 

(setq _sq (lambda (#) (* # #)))

Posted

Alan,

 

I looked up apply Function,

 

Passes a list of arguments to, and executes, a specified function.

 

Thanks

Posted
Alan,

 

I looked up apply Function,

 

Passes a list of arguments to, and executes, a specified function.

 

Thanks

 

Hope it helps.:)

And good luck keeping your head on straight while typing everything out. :wacko:

Posted

Nice one Alan :thumbsup:

 

This is the only improvement I can see:

 

(defun foo (L r O D tt / _sq n)
 (setq _sq (lambda (#) (* # #)))

 (cond (  (minusp (setq n (- (_sq (- L r)) (_sq (/ (* O D) (- 2 tt r)))))) nil)

       (  (- L (sqrt n)))))

Posted

I know,

 

Its like putting 30lbs of s%#t in a 5lb bag.

Posted

Now you tripped me up Lee,

 

Whats with the condition?

Posted
Now you tripped me up Lee,

 

Whats with the condition?

 

Square roots of negative numbers don't exist in the Reals :)

Posted
Square roots of negative numbers don't exist in the Reals :)

But in that case, could'nt you just use abs in there someplace.

Posted
Nice one Alan :thumbsup:

 

This is the only improvement I can see:

 

(defun foo (L r O D tt / _sq n)
 (setq _sq (lambda (#) (* # #)))

 (cond (  (minusp (setq n (- (_sq (- L r)) (_sq (/ (* O D) (- 2 tt r)))))) nil)

       (  (- L (sqrt n)))))

 

HaHa

I guess we can't have i. Good catch.

Posted
But in that case, could'nt you just use abs in there someplace.

 

But then you are changing the formula... :wink:

Posted
But then you are changing the formula... :wink:

 

Ahh good point.:oops:

Posted

One minor change to #2:

 

(defun foo (L r O D tt / _sq n)
 (setq _sq (lambda (#) (* # #)))

 (cond (  (minusp (setq n (- (_sq (- L r)) (_sq (/ (* O D) (- 2. tt r)))))) nil)

       (  (- L (sqrt n)))))

Posted
One minor change to #2:

 

Excellent spot - that would have you looking for days for that bug... :cry:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...