Git Product home page Git Product logo

symbolic's Introduction

Symbolic Package for GNU Octave

An implementation of a symbolic toolbox using SymPy.

https://octave.sourceforge.io/symbolic

https://github.com/gnu-octave/symbolic

Goals

Feature parity with the other symbolic toolboxes.

Screenshot 1

Screenshot 2

How to Install

  1. The dependencies are Octave, Python, and SymPy. Consult the SymPy website for details on how to install SymPy.

  2. Start Octave.

  3. At Octave prompt type pkg install -forge symbolic.

  4. At Octave prompt, type pkg load symbolic.

  5. At Octave prompt, type syms x, then f = (sin(x/2))^3, diff(f, x), etc.

How to install on Ubuntu

  1. Install the dependencies with sudo apt install octave python3-sympy.
  2. Follow steps 2--5 above.

How to Install on Windows

  1. Get Octave for Windows.

  2. At the Octave prompt, type pkg install -forge symbolic.

  3. At the Octave prompt, type pkg load symbolic.

  4. At the Octave prompt, type syms x, then f = (sin(x/2))^3, diff(f, x), etc.

If you encounter any difficulties (even minor ones) please read and if possible help us improve the wiki page on Windows Installation.

How to Install on Matlab

Although this package is designed for GNU Octave, it will work with Matlab. Currently only the slower system()-based communication is available.

  1. Download the latest release, e.g., octsympy-matlab-2.7.0.tar.gz.

  2. Unzip it somewhere and add it to your Matlab Path.

The .m files for Matlab have been reformatted for Matlab comment conventions, but are otherwise the same as the Octave source.

How to Help

We have a list of things to work on tagged help wanted. Some of these should be quite easy to fix and would be a great way to get involved. Come join us!

How to hack on the code:

  1. Clone the repo with git (preferred, but you can use the "Download ZIP" instead if you want).

  2. Run Octave in the inst/ directory. It should be safe to do this even if you have the released version of the package installed (but not loaded).

Implementation

Python code is generated to do the actual work. Each sym object keeps a text field for display purposes and a string (a SymPy srepr). The objects are communicated between Python and Octave by passing the srepr string back-and-forth. Currently pure m-file (and Python) implementation, no code to be compiled.

Related Projects

  • There was a previous "symbolic" package in Octave Forge based on GiNaC. Its history has now been merged into this project.

  • "SymPy CAS" by Jonathan Lister. Calls SymPy commands using system().

symbolic's People

Contributors

alexvong243f avatar billchenchina avatar brynne8 avatar carandraug avatar cbm755 avatar chrisjohgorman avatar feralber avatar genuinelucifer avatar i7tiol avatar jmfrank63 avatar jweaton avatar latot avatar maprieto avatar mass2010chromium avatar mmuetzel avatar mohtamohit avatar mtmiller avatar nvs-abhilash avatar opoplawski avatar osellag avatar rlaboiss avatar tpapastylianou avatar trueutkarsh avatar yoihito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symbolic's Issues

1x1 matrix not same as scalar

Several ways to make 1x1 matrices which in sympy are not same as scalars:

  1. inner product for example
  2. grow an empty sym into a 1x1 sym
  3. (probably) via slicing (but that doesn't work yet, Bug #14)

One way to fix this is on conversion back from python, replace them with scalars.

Why do I need to use subsref within @sym/myfcn.m?

I've overloading subrefs() and it works fine. But within my own @sym/ directory, I have to manually use subrefs() like this:

x(i)   % <-- gives error
% so workaround:
idx.type = '()';
idx.subs = {j};
subsref(x, idx);

The error is:

error: myfcn.m: A(I): index out of bounds; value 2 out of bound 1
error: called from:

It's calling the superclass subsref (I think). Which in my case, will report [1 1] or something wrong for my array.

FWIW, same thing in Matlab 2008:

??? Index exceeds matrix dimensions.

SymPy or Octave arrays?

I've gone back and forth on this:

  1. Using SymPy's Matrix for arrays. Currently the master branch does this.

  2. Use native arrays (only scalars go to SymPy). See octarray branch for this approach.

Anyway, make a decision and close this :)

python command cannot contain %

Workaround: It can be escaped as %% in python_cmd() and as %%%% in evalpy.

This is due to gratuitous sprintf() when all we really want is to unescape \n.

String input passed to S(): sym('beta') fails and similar issues

Currently, sym('bar') calls S('bar') in SymPy. S() is smart. S('beta') gives the beta function. Perhaps we don't want that.

  1. We might sometimes want something dumb, like Symbol('beta'). But then Symbol('1') is not One, its just a symbol, which is not good. So we'd have to work around for numbers.
  2. Alternative? detect special inputs like 'gamma' and 'beta' and pass them to Symbol instead of S? Then we have a huge list of special cases to maintain. But surely better than the above? At least oo, nan, zoo would still work as expected. I think I'll do this for now.

FWIW, Matlab SMT does 1. It allows plain beta, gamma, etc: "syms beta gamma". They also also "syms sin". I.e., its complete user's responsibility. If she wants a symbol called "sin" or "limit" then so be it.

Array construction fails with row of doubles

A = [sym(0) 1; sym(2) 3];
B = [sym(0) 1; 2 3];

A works but B fails on Octave 3.6.4 and 3.8.1 with:

error: octave_base_value::map_value(): wrong type argument 'scalar'
error: octave_base_value::parent_class_name_list(): wrong type argument 'scalar'

It works in Matlab, maybe an Octave bug?

Loss of precision when doubles move between octave and python

python generates C "%a" formatting:

0.11 -> '0x1.c28f5c28f5c29p-4'

java might work, or write some custom code. In first instance, I'll use a string with many digits but it would be good to pass the bit-exact double precision value back from SymPy.

treatment of SymPy Matrix's with True/False entries

Some commands return matrices of bools. We want these to become "logical"s in Octave. Currently dealt with in an adhoc manner (e.g., see isprime).

Perhaps something more general python_header.py would be good?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.