My Math Forum  

Go Back   My Math Forum > College Math Forum > Number Theory

Number Theory Number Theory Math Forum


Reply
 
LinkBack Thread Tools Display Modes
September 17th, 2014, 01:41 PM   #1
Newbie
 
Joined: Sep 2014
From: England

Posts: 2
Thanks: 0

Lightbulb Fundamental operations and recursive operations

Hi folks,

I'm trying to create a mathematical formula evolution program, I represent formulae as node trees which acts as the genome, which in (my) theory can express any formula that can exist by using numbers as the leaf nodes, and the four fundamental math operations namely; Add, Subtract, Multiply and Divide.

I'm assuming all other mathematical operations are shorthand ways of writing functions that the above make up. I also assume all operators take either 1 or 2 value inputs. Like, 2x4 has two numerical inputs.

However, if you spend five minutes looking into mathematical operations on the internet, you find all sorts of other ones, like the logarithm function, modulus function, sine and cosine, the list goes on.

Now, what I really need to know, is for the purposes of defining a formula in the smallest amount of characters (characters as in letters, numbers and operators), what are the mathematical operators I need?

Another example may explain what I mean: If I only use the fundamental operators, I'd have to write "5x5x5x5", which is seven characters, but I could have written it as "5^4" which is only three. A more pressing example is factorials, so "6x5x4x3x2x1" is 11 characters long, and very unlikely to happen by chance in my program, whereas "6!" is only 2 characters, and much more likely and useful!

So, any common math operators you think I should be including would be great! So far, I have "Add, Subtract, Multiply, Divide, Cosine, Sine, Tangent, Modulus, Factorial, Root, Power, Logarithm"... Any others anyone can think of would be a MASSIVE HELP!

I'll be checking frequently, and giving feedback on suggestions
DanRayson is offline  
 
September 17th, 2014, 02:48 PM   #2
Math Team
 
topsquark's Avatar
 
Joined: May 2013
From: The Astral plane

Posts: 2,162
Thanks: 879

Math Focus: Wibbly wobbly timey-wimey stuff.
sinh, cosh, tanh

-Dan
topsquark is online now  
September 18th, 2014, 06:02 AM   #3
Global Moderator
 
CRGreathouse's Avatar
 
Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
You may wish to look at the similar project ries
RIES - Find Algebraic Equations, Given Their Solution at MROB
and see if you can glean anything there.

As for operations, I'm partial to Lambert's W. Also useful is the Riemann's zeta function. For great generality you could implement (or more likely, find an existing implementation of) the hypergeometric function -- although it doesn't take 1 or 2 arguments like your other functions but 4 (!).
CRGreathouse is offline  
September 18th, 2014, 12:01 PM   #4
Newbie
 
Joined: Sep 2014
From: England

Posts: 2
Thanks: 0

Thank you both for your replies!

Particularly you, Greathouse, that link you provided is proving a facinating read, I'm going through the comments at the top of the code script, and buried in there is a list of operators they've used.

Their goal is slightly different to mine, but it's proving to be a great help! I'm working out the solution to a series rather than a single number, but very closely related otherwise.

Thank you!

Here's the bit I'm finding most useful;

Code:
sym  stack-effect  description
 0x1  --            Phantom symbol for argument-reversed version of -
 0x2  --            Phantom symbol for argument-reversed version of /
 0x4  --            Phantom symbol for argument-reversed version of ^

 ' '  --            Blank space: no operation (for --eval-expression)
  0   (-- 0)        The constant 0.0 (not currently used, but will have a
                    role soon as part of --numeric.anagram)
  1   (-- 1)        The constant 1.0
  2   (-- 2)        The constant 2.0
  3   (-- 3)        The constant 3.0
  4   (-- 4)        The constant 4.0
  5   (-- 5)        The constant 5.0
  6   (-- 6)        The constant 6.0
  7   (-- 7)        The constant 7.0
  8   (-- 8)        The constant 8.0
  9   (-- 9)        The constant 9.0
  !   (a -- f)      Factorial monad f(x) = x! = Gamma[x+1] (reserved, not
                    yet implemented)
  #   (n d -- x)    Digit paste operator x(n,d) = 10*n+d (reserved, not yet
                    implemented. This is to make --numeric.anagram more useful)
  %   (a b -- m)    (reserved for modulo or remainder?)
  ^   (a b -- f)    Power: f(a,b) = a^b
  *   (a b -- p)    Multiply+ p(a,b) = a*b
  (   --            Comment delimiter; used to bracket custom symbol names;
                    used as a placeholder during infix translation
  )   --            Comment delimiter; used to bracket custom symbol names;
                    used as a placeholder during infix translation
  -   (a b -- d)    Subtract: d(a,b) = a-b
  +   (a b -- s)    Add: s(a,b) = a+b
  :   --            Function definition start
  ;   --            Function definition end
  .   --            Placeholder for multiplication during infix formatting
  /   (a b -- r)    Divide: r(a,b) = a/b
  A   (x -- a)      Arctangent a(x) = atan(x) (reserved, not yet used)
  C   (x -- c)      Cosine c(x) = cos(pi x)
  E   (x -- f)      Exponential function f(x) = e^x
  G   (x -- g)      Gamma function g(x) = Gamma[x] = (x-1)! (reserved, not
                    yet implemented)
  I   (x -- x)      Identity function x(x) = x (not used in expressions, but
                    used as a placeholder during infix translation)
  L   (a b -- l)    Arbitrary logarithm l(a,b) = log_b(a)
  S   (x -- s)      Sine s(x) = sin(pi x)
  T   (x -- t)      Tangent t(x) = tan(pi x)
  W   (x -- w)      Lambert W function, e.g. w(10.0) = 1.74553...
  e   (-- e)        The constant 2.71828...
  f   (-- f)        The constant 1.61803...
  l   (a -- l)      Natural logarithm: l(a) = ln(a)
  n   (a -- n)      Negate: n(a) = -a
  p   (-- p)        The constant 3.14159...
  q   (a -- q)      Square root: q(a) = sqrt(a)
  r   (a -- r)      Reciprocal: r(a) = 1/a
  s   (a -- s)      Square: s(a) = a*a
  v   (a b -- v)    Root: v(a,b) = a^(1/b)
  x   (-- x)        The user's target number
DanRayson is offline  
September 18th, 2014, 06:26 PM   #5
Senior Member
 
Joined: Aug 2008
From: Blacksburg VA USA

Posts: 346
Thanks: 6

Math Focus: primes of course
(suggestions, probably from a programming vantage)

you may want some set of floor/ceiling/round/truncate operators
you need parity, which you can get via modulus/remainder ops.
root seems duplicitious with power
if you add negation, then subtract falls out of addition with negated values.
similarly, adding inverse allows division to fall out of multiply, root from power
you might consider some sort of venn operations (and/or etc)
Depending on your ultimate objective, binary may be of particular use, and therefore bitwise operations
maybe "assignment" is implied? a=b
what of comparators (<,>,!=,==)
billymac00 is offline  
September 18th, 2014, 10:12 PM   #6
Banned Camp
 
Joined: Dec 2012

Posts: 1,028
Thanks: 24

Sum and difference. all the rest are human inventions ;-P
complicatemodulus is offline  
Reply

  My Math Forum > College Math Forum > Number Theory

Tags
fundamental, operations, recursive



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Order of Operations u6ik New Users 3 December 21st, 2012 05:12 PM
Inverse Operations watkd Algebra 3 August 27th, 2011 06:03 AM
Order of operations melorock089 Calculus 2 September 22nd, 2009 04:36 AM
order of operations floaty Elementary Math 3 January 7th, 2009 07:43 AM
Equal operations SidT New Users 3 June 10th, 2008 08:51 AM





Copyright © 2019 My Math Forum. All rights reserved.