I want to propose the following changes to the output format of find_fit
and solve:
for find_fit the current output format is a list of equations:
sage: data = [(i, 1.2 * sin(0.5*i-0.2) + 0.1 * normalvariate(0, 1)) for
i in xsrange(0, 4*pi, 0.2)]
sage: var('a, b, c, x')
sage: model(x) = a * sin(b * x - c)
sage: find_fit(data, model)
[a == 1.2204167610363676, b == 0.50171964598627838, c ==0.22401763827376933]
or a dictionary:
sage: find_fit(data,model,solution_dict=True)
{c: 0.22401763827376933, b: 0.50171964598627838, a: 1.2204167610363676}
I'd like to get an expression where the values found for the parameters
are put in the model given to find_fit:
sage: find_fit(data, model)
1.2204167610363676*sin(0.50171964598627838 *x -0.22401763827376933 )
For solve the current output format depends on the input:
sage: var('x y')
sage: eq1=x+4==0
sage: eq2=x^2+4*x+2==0
sage: sys1=x+y==1
sage: sys2=x-2*y==-2
sage: solve(eq1,x)
[x == -4]
A list containing solutions (even when there is only one solution).
sage: solve(eq2,x)
[x == -sqrt(2) - 2, x == sqrt(2) - 2]
A list containing solutions when there is more than one solution
solve([sys1,sys2],x,y)
[[x == 0, y == 1]]
A list containing a list containing solutions (this is the worst)
The format I would like to see is:
sage: solve(eq1,x)
x == -4
A single equation
sage: solve(eq2,x)
[x == -sqrt(2) - 2, x == sqrt(2) - 2]
This one is fine
solve([sys1,sys2],x,y)
[x == 0, y == 1]
Just a list of solutions. It is harder to work with the solutions if
they are inside another list.
I would like all of this changes to become standard outputs, although I
imagine that that would produce some backwards compatibility issues.
thanks!
Oscar
--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org