
Student Support Forum: 'Function that fits a1,a2...,a5' topicStudent Support Forum > General > "Function that fits a1,a2...,a5"
| Author |
Comment/Response |
Søren
|
08/24/11 08:25am
Hi there.
b is a number and 0 < b < 1
a1, a2...,a5 are either 0 or 1.
Here is the thing:
Total[Table[Subscript[a,n]/(2^n),{n,1,5}]]]
This sum above must be as close to b as possible.
How do I make Mathematica choose a1, a2...,a5?
I want it to be like:
f[b_]:= ?????
f[1/2] = {1,0,0,0,0} ; best fit of
f[0.344] = {0,1,0,1,1} ; {a1,a2,a3,a4,a5}
URL: , |
|
| | | |
 | |
|