symbolic, lazy Min

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

symbolic, lazy Min

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.

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


Reply | Threaded
Open this post in threaded view
|

Re: symbolic, lazy Min

Andreas Weber-6
Am 25.10.18 um 18:05 schrieb CS Suehs:
> What are the code-pasting etiquette rules on this list?
> ... Would a quick 10-line example here be ok?

Yes, absolutely.

-- Andy


Reply | Threaded
Open this post in threaded view
|

Re: symbolic, lazy Min

Colin Macdonald-2
In reply to this post by CS Suehs
On 2018-10-25 9:05 a.m., CS Suehs wrote:

> 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].

Here is a workaround:

 >> 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/cbm755/octsympy/issues/876

Colin


Reply | Threaded
Open this post in threaded view
|

Re: symbolic, lazy Min

Colin Macdonald-2
On 2018-10-25 10:06 a.m., CS Suehs wrote:
> 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