Skip to content

Commit

Permalink
Removing unwanted files, and updating symengine version
Browse files Browse the repository at this point in the history
  • Loading branch information
rajithv committed Jul 8, 2016
1 parent e447e97 commit 61cee1a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 297 deletions.
2 changes: 1 addition & 1 deletion ext/symengine/symengine_utils.c
Expand Up @@ -83,7 +83,7 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2)
{
VALUE ret = check_sympify(operand2, cbasic_operand2);
if (ret == Qfalse) {
rb_raise(rb_eTypeError, "%s can't be coerced into a SymEngine type.",
rb_raise(rb_eTypeError, "%s can't be coerced into SymEngine::Basic",
rb_obj_classname(operand2));
}
}
Expand Down
325 changes: 30 additions & 295 deletions notebooks/beginner.ipynb
Expand Up @@ -62,6 +62,35 @@
"SymEngine.ascii_art"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"or create a variable"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"#<SymEngine::Basic:0x00000001e95290>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"basic = SymEngine::Basic.new"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -585,305 +614,11 @@
"source": [
"k.expand.to_s"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## SymEngine::RealDouble\n",
"\n",
"SymEngine::RealDouble can be constructed by converting any ruby Float into SymEngine"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"d = SymEngine(1.2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## SymEngine::ComplexDouble\n",
"SymEngine::ComplexDouble can be constructed by converting any ruby Complex into SymEngine"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"c = SymEngine(Complex(2.3, 3.2))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## SymEngine::RealMPFR\n",
"SymEngine::RealMPFR can be constructed either by converting any Ruby BigDecimal into SymEngine, or using the constructor to express any real number with a given number of bits of precision"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"require 'bigdecimal'\n",
"r1 = SymEngine(BigDecimal(\"12.3\"))\n",
"r2 = SymEngine::RealMPFR.new(12.3, 200)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## SymEngine::ComplexMPC\n",
"SymEngine::RealMPC can be constructed by arithmatic operations of any SymEngine::RealMPFR objects, as shown below."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"i = SymEngine:I\n",
"c1 = r1 + i * r2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## SymEngine::Constant - SymEngine Constants\n",
"\n",
"SymEngine offers the following constants"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"i = SymEngine::I\n",
"e = SymEngine::E\n",
"eg = SymEngine::EULER_GAMMA\n",
"pi = SymEngine::PI\n",
"\n",
"i.inspect + e.inspect + eg.inspect + pi.inspect"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## SymEngine::TrigFunction\n",
"\n",
"sin, cos, tan, cosec, sec, cot, asin, acos, atan, acosec, asec, acot are available as shown below:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"i1 = SymEngine::sin(pi)\n",
"i2 = SymEngine::cos(0.2)\n",
"i3 = SymEngine::tan(pi/4)\n",
"i4 = SymEngine::csc(pi/2)\n",
"i5 = SymEngine::sec(0.2)\n",
"i6 = SymEngine::cot(pi/4)\n",
"\n",
"print \"sin(pi): \", i1,\"\\ncos(0.2): \", i2, \"\\ntan(pi/4): \", i3, \"\\ncsc(pi/2): \", i4, \"\\nsec(0.2): \", i5,\"\\ncot(pi/4): \", i6, \"\\n\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"i1 = SymEngine::asin(1)\n",
"i2 = SymEngine::acos(0)\n",
"i3 = SymEngine::atan(5)\n",
"i4 = SymEngine::acsc(1)\n",
"i5 = SymEngine::asec(0.2)\n",
"i6 = SymEngine::acot(0.5)\n",
"\n",
"print \"i1: \", i1,\"\\ni2: \", i2, \"\\ni3: \", i3, \"\\ni4: \", i4, \"\\ni5: \", i5,\"\\ni6: \", i6, \"\\n\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## SymEngine::HyperbolicFunction\n",
"sinh, cosh, tanh, cosech, sech, coth, asinh, acosh, atanh, acosech, asech, acoth are available as shown below:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"i1 = SymEngine::sinh(pi)\n",
"i2 = SymEngine::cosh(0.2)\n",
"i3 = SymEngine::tanh(pi/4)\n",
"i4 = SymEngine::csch(pi/2)\n",
"i5 = SymEngine::sech(0.2)\n",
"i6 = SymEngine::coth(pi/4)\n",
"\n",
"print \"sinh(pi): \", i1,\"\\ncosh(0.2): \", i2, \"\\ntanh(pi/4): \", i3, \"\\ncsch(pi/2): \", i4, \"\\nsech(0.2): \", i5,\"\\ncoth(pi/4): \", i6, \"\\n\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"i1 = SymEngine::asinh(1)\n",
"i2 = SymEngine::acosh(0)\n",
"i3 = SymEngine::atanh(5)\n",
"i4 = SymEngine::acsch(1)\n",
"i5 = SymEngine::asech(0.2)\n",
"i6 = SymEngine::acoth(0.5)\n",
"\n",
"print \"i1: \", i1,\"\\ni2: \", i2, \"\\ni3: \", i3, \"\\ni4: \", i4, \"\\ni5: \", i5,\"\\ni6: \", i6, \"\\n\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## NTheory Functions\n",
"\n",
"Several Number Theory functions are available in SymEngine.\n",
"\n",
"GCD and LCM"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"gcd = SymEngine::gcd(45, 40)\n",
"lcm = SymEngine::lcm(45, 40)\n",
"\n",
"print \"for 45 and 40,\\ngcd is: \", gcd, \"\\nlcm is: \",lcm, \"\\n\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next Prime"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"np = SymEngine::nextprime(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Quotient"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"q = SymEngine::quotient(5, 2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lucas and Fibonacci series"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"l = SymEngine::lucas(3)\n",
"f = SymEngine::fibonacci(3)\n",
"\n",
"p l, f"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Binomials"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"b = SymEngine::binomial(5, 2)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Ruby 2.3.0",
"display_name": "Ruby 2.2.0",
"language": "ruby",
"name": "ruby"
},
Expand Down
2 changes: 1 addition & 1 deletion symengine_version.txt
@@ -1 +1 @@
0c17ca9d88f25881c6d0ca382c26b2eb392b9b48
fd7d2be06d935e2625a56fe0fd637925de2420ff

0 comments on commit 61cee1a

Please sign in to comment.