Discussion:
symbolic, lazy Min
CS Suehs
2018-10-25 16:05:04 UTC
Permalink
Greetings, all,

I have been experiencing some pain trying to use sympy's Min from Octave's
symbolic
math capabilities. I have not been able to figure out how to dissuade
Octave from eagerly evaluating the Min. I want an expression with a Min in
it, not an immediate attempt to evaluate the two expressions. I wonder, if
Octave is confusing it with its own min, or failing to translate the sym
min to sympy's Min. Perhaps, in my ignorance, I am not correctly
specifying the exact Min.

What are the code-pasting etiquette rules on this list? Should I post a
pastebin? Would a quick 10-line example here be ok?

Thank you!
-s
Andreas Weber
2018-10-25 16:26:32 UTC
Permalink
Post by CS Suehs
What are the code-pasting etiquette rules on this list?
... Would a quick 10-line example here be ok?
Yes, absolutely.

-- Andy
Colin Macdonald
2018-10-25 16:59:46 UTC
Permalink
Post by CS Suehs
Greetings, all,
I have been experiencing some pain trying to use sympy's Min from
Octave's symbolic
math capabilities.  I have not been able to figure out how to dissuade
Octave from eagerly evaluating the Min.  I want an expression with a Min
in it, not an immediate attempt to evaluate the two expressions.  I
wonder, if Octave is confusing it with its own min, or failing to
translate the sym min to sympy's Min.  Perhaps, in my ignorance, I am
not correctly specifying the exact Min.
Probably this is because min(x,y) does not work correctly yet [1].
Post by CS Suehs
syms x y
A = python_cmd('return Min(*_ins)', x, y)
syms p positive
B = python_cmd('return Min(*_ins)', p, 2*p)
I think [1] would be easy to fix properly and I'd love some help! Just
find "@sym/min.m" and edit it. It needs to call sympy's "Min()" like
the above examples.

[1] https://github.com/
Colin Macdonald
2018-10-25 19:05:58 UTC
Permalink
Ah! ok!
I am willing to help. Let me see about pulling down source for octsympy.
You can even edit your existing install in place if you want to quick
way to get started...
What is the proper syntax in Octave for specifying a particular
function of a particular namespace? Was I doing that correctly?
Briefly, a function defined in "@sym/min.m" will get called whenever any
argument is of class "sym".

So "@sym/min" is called for "min(2, sym(3))" but not for "min(2, 3)".

Colin

Loading...