math - Programming mathemathics: how to expand a function -


lets have math function defined recursively. so:

t(1)(x) = 1 t(n)(x) = 2x*t(n-1)(x)-1 

so:

t(1)(x) = 1 t(2)(x) = 2x*1-1 = 2x-1 t(3)(x) = 2x*(2x-1)-1 = 4x^2 - 2x - 1 /* , on... */ 

basically, know how write program count t(15)(x) if x given. thats not problem. wonder, - how write program give me polynomial t(10)(x) (one looking like: 16x^4 + 3x^3 ...).

in nutshell: how can recursively count math expression, using x variable (not set).

any appreciated,

paul

based upon comments, believe there 4 options, in order of complexity.

first, implement explicit formula given polynomial looking for, if exist. in case of chebyshev polynomials, explicit formula (3rd sum top) fitting needs exist.

if, however, looking more general, i.e. more 1 type of polynomial, create explicit list of polynomials absurd order , string replace using user supplied variable name. in systems, won't take lot of memory.

thirdly, if wish remain general , still recursively produce polynomials, tap computer algebra system, mathematica. instance, can access mathematica through mathlink, or use instance of webmathematica, or scrape output wolframalpha. although, think you'd run copyright issues last one.

lastly, complex , general create abstract syntax tree. if can use c++, i'd @ boost.proto you. but, if create yourself, you'd have 3 types of binary ops, add, multiply, , power , 2 types of leaf nodes, coefficient , variable. now, massage tree form can use have move through tree , apply transformation rules: replace subtree , interchange parent , child. replace alter tree applying standard math rules, such 2 + 2 becomes 4 , x * x becomes x2. but, real work in interchanging parent , child nodes, used apply distributive law (mult -> add becoming add -> mult) , providing opportunities use replace.

the first 2 options far easiest, , i'd go first if available. said, i'd find implementing either mathlink interface or syntax tree more interesting do.

edit: clarify mean interchanging parent child, consider case of n = 2.

graphic showing basic transformation of expression tree.

which effects 4 nodes: "plus", both "times", , coefficient 1. but, easy see reduce overall number of nodes eliminating second "times."


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -