On Mar 18, 8:14 pm, "dean moore" <
deanlorenmo...@gmail.com> wrote:
> I was fiddling, trying to hack a solution to my recent max / min value
> hassles, and
> was playing with solve(), discussed
> here<
http://www.sagemath.org/doc/html/ref/module-sage.calculus.equations.html>.
>
> I wondered if this was a strict polynomial thing, but, snippets:
> *
> f = x*sin(x^2)
> solve(f(x) == 0)*
>
> gave
>
> *[x == 0]
> *
> and,
> *
> f = cos(x^2 -1)
> solve(f(x) == 0)*
>
> gave two nice answers,
> *
> [x == -sqrt(pi + 2)/sqrt(2), x == sqrt(pi + 2)/sqrt(2)]*
>
> but returning to the first example & dividing by *x* cubed:
> *
> f = x*sin(x^2)/x^3
> solve(f(x) == 0)*
>
> gave*
>
> [x == 0]*
>
> and*
>
> f = x*sin(x^2)/x^4
> solve(f(x) == 0)*
>
> whose functiuon can't be "limited" to make sense at x = 0, gave
> *
> [x == 0]*
The above look like bugs to me, but they may be difficult to fix.
> Again, how functions are defined seems important,
> *
> def f(x)
> return cos(x)
> solve(f, x)*
>
> gave*
>
> Syntax Error:
> def f(x)
> *
This is because you're missing the colon at the end of the line "def
f(x)". If you add the colon to correctly define the function, you can
then get
sage: solve(f(x) == 0)
[x == pi/2]
But yes, it does matter how the function is defined. With "def", you
get a Python function that takes a symbolic expression and returns a
symbolic expression; the other examples above gave symbolic
functions.
Carl