Click here to Skip to main content
15,908,931 members
Home / Discussions / Algorithms
   

Algorithms

 
Questionhow to convert a string to a mathematical function Pin
nta_388626-Sep-07 2:55
nta_388626-Sep-07 2:55 
AnswerRe: how to convert a string to a mathematical function Pin
David Crow26-Sep-07 4:48
David Crow26-Sep-07 4:48 
AnswerRe: how to convert a string to a mathematical function Pin
Dan Neely26-Sep-07 5:25
Dan Neely26-Sep-07 5:25 
GeneralRe: how to convert a string to a mathematical function Pin
El Corazon26-Sep-07 9:45
El Corazon26-Sep-07 9:45 
AnswerRe: how to convert a string to a mathematical function Pin
Russell'27-Sep-07 0:35
Russell'27-Sep-07 0:35 
AnswerRe: how to convert a string to a mathematical function Pin
Urs Enzler27-Sep-07 1:16
Urs Enzler27-Sep-07 1:16 
AnswerRe: how to convert a string to a mathematical function Pin
Luc Pattyn27-Sep-07 3:29
sitebuilderLuc Pattyn27-Sep-07 3:29 
AnswerRe: how to convert a string to a mathematical function Pin
PICguy9-Oct-07 20:57
PICguy9-Oct-07 20:57 
If you are using Rexx then

interpret say "string"

Except you first need to write sin(x) and other functions you use in Rexx. You also need to use Rexx rules for syntax.

Rexx can compile and execute on the fly.

With just a little more detail in dos one might type

rexx math 1.2*4.7

5.64 prints

The file math.cmd contains

/* execute incomming statement */
numeric digits 40
arg cmd
interpret say cmd

It's been a while but saving x to a environment variable or some such is not that hard.

My 40 digit ln() in ln.cmd is

/* ln(x) */
numeric digits 40
arg x

/* prescale to put x into reasonable range */

xp = 0
if x > 2 then do until x < 2
xp = xp + 1
x = x / 2
end

/* now that x <=2 compute ln(x)
method from Abramowitz etal section 4.1.39
ln(2) to 40 places takes 26 loops */

z = x-1
val = 0
do t = 26 to 1 by -1
t2z = t*t*z
val = t2z / (t+t+val+1)
val = t2z / (t+t+val)
end
val = z / (val+1)

/* account for prescale */

if xp = 0 then return val
return (const(ln2)*xp) + val
QuestionWhich algorithm fits best ? Pin
kkadir24-Sep-07 9:19
kkadir24-Sep-07 9:19 
AnswerRe: Which algorithm fits best ? Pin
PICguy24-Sep-07 14:21
PICguy24-Sep-07 14:21 
GeneralRe: Which algorithm fits best ? Pin
kkadir25-Sep-07 3:36
kkadir25-Sep-07 3:36 
AnswerRe: Which algorithm fits best ? Pin
Russell'26-Sep-07 0:04
Russell'26-Sep-07 0:04 
GeneralRe: Which algorithm fits best ? Pin
kkadir26-Sep-07 11:06
kkadir26-Sep-07 11:06 
GeneralRe: Which algorithm fits best ? Pin
Russell'26-Sep-07 22:07
Russell'26-Sep-07 22:07 
GeneralRe: Which algorithm fits best ? Pin
mulletcheese28-Sep-07 6:02
mulletcheese28-Sep-07 6:02 
QuestionCode for Travelling Salesman Problem Pin
laremtj24-Sep-07 8:56
laremtj24-Sep-07 8:56 
AnswerRe: Code for Travelling Salesman Problem Pin
Paul Conrad24-Sep-07 13:18
professionalPaul Conrad24-Sep-07 13:18 
Questionall combinations from a set of numbers Pin
Tom Deketelaere24-Sep-07 4:26
professionalTom Deketelaere24-Sep-07 4:26 
AnswerRe: all combinations from a set of numbers Pin
Luc Pattyn24-Sep-07 6:27
sitebuilderLuc Pattyn24-Sep-07 6:27 
GeneralRe: all combinations from a set of numbers Pin
Hoss Fly24-Sep-07 15:34
Hoss Fly24-Sep-07 15:34 
GeneralRe: all combinations from a set of numbers Pin
cp987624-Sep-07 15:57
cp987624-Sep-07 15:57 
GeneralRe: all combinations from a set of numbers Pin
Hoss Fly24-Sep-07 16:37
Hoss Fly24-Sep-07 16:37 
GeneralRe: all combinations from a set of numbers Pin
Stephen Hewitt24-Sep-07 20:33
Stephen Hewitt24-Sep-07 20:33 
GeneralRe: all combinations from a set of numbers Pin
Luc Pattyn25-Sep-07 0:52
sitebuilderLuc Pattyn25-Sep-07 0:52 
AnswerRe: all combinations from a set of numbers Pin
kkadir24-Sep-07 10:27
kkadir24-Sep-07 10:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.