diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index c176f13e..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,206 +0,0 @@ -name: Build and test symengine -on: [push, pull_request] - -jobs: - build: - runs-on: ${{ matrix.OS }} - strategy: - fail-fast: false - matrix: - include: - - BUILD_TYPE: Debug - WITH_BFD: yes - PYTHON_VERSION: '3.12' - TEST_SYMPY: yes - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Debug - WITH_BFD: yes - PYTHON_VERSION: '3.11' - TEST_SYMPY: yes - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Debug - WITH_BFD: yes - PYTHON_VERSION: '3.10' - TEST_SYMPY: yes - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Debug - WITH_BFD: yes - PYTHON_VERSION: '3.9' - TEST_SYMPY: yes - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.13' - BUILD_SHARED_LIBS: yes - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.13' - WITH_MPFR: yes - INTEGER_CLASS: gmpxx - WITH_NUMPY: no - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.13' - WITH_MPC: yes - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Release - WITH_MPFR: yes - PYTHON_VERSION: '3.13' - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.9' - WITH_MPC: yes - OS: ubuntu-22.04 - CC: gcc - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.9' - WITH_MPC: yes - INTEGER_CLASS: flint - WITH_FLINT: yes - OS: ubuntu-22.04 - CC: gcc - - #- BUILD_TYPE: Debug - # PYTHON_VERSION: '3.9' - # WITH_BFD: yes - # WITH_PIRANHA: yes - # OS: ubuntu-22.04 - # CC: gcc - - - BUILD_TYPE: Debug - PYTHON_VERSION: '3.13' - WITH_BFD: yes - BUILD_SHARED_LIBS: yes - OS: ubuntu-22.04 - CC: clang - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.13' - WITH_NUMPY: yes - OS: ubuntu-22.04 - CC: clang - - - BUILD_TYPE: Debug - PYTHON_VERSION: '3.12' - WITH_SYMPY: yes - WITH_LLVM: 18 - WITH_SCIPY: yes - WITH_LATEST_GCC: yes - INTEGER_CLASS: 'boostmp' - PYTEST_ADDOPTS: '-k "not integer_nthroot"' - OS: ubuntu-24.04 - CC: gcc # ubuntu nobel uses gcc-13 - #EXTRA_APT_REPOSITORY: 'deb http://apt.llvm.org/jammy/ llvm-toolchain-nobel-18 main' - EXTRA_APT_PACKAGES: 'llvm-18' - - - BUILD_TYPE: Debug - PYTHON_VERSION: '3.13' - WITH_SCIPY: yes - WITH_LLVM: 5.0 - OS: macos-13 - CC: clang - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.9' - WITH_NUMPY: no - OS: macos-13 - CC: clang - - - BUILD_TYPE: Debug - PYTHON_VERSION: '3.13' - WITH_NUMPY: no - OS: macos-13 - CC: gcc - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.13' - OS: macos-13 - CC: gcc - - - BUILD_TYPE: Release - PYTHON_VERSION: '3.11' - OS: ubuntu-22.04 - WITH_MPC: yes - WITH_MPFR: yes - WITH_FLINT: yes - WITH_FLINT_PY: yes - WITH_SCIPY: yes - WITH_DOCS: yes - INTEGER_CLASS: flint - TEST_SYMPY: yes - CC: gcc - - steps: - - - uses: conda-incubator/setup-miniconda@v3 - if: matrix.MSYS_ENV == '' - with: - activate-environment: symengine - channel-priority: strict - architecture: x86_64 - channels: conda-forge - conda-remove-defaults: "true" - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build and test symengine - shell: bash -el {0} - run: | - source bin/test_symengine_unix.sh - env: - PYTEST_ADDOPTS: ${{ matrix.PYTEST_ADDOPTS }} - USE_GLIBCXX_DEBUG: ${{ matrix.USE_GLIBCXX_DEBUG }} - WITH_MPFR: ${{ matrix.WITH_MPFR }} - BUILD_BENCHMARKS: ${{ matrix.BUILD_BENCHMARKS }} - WITH_LLVM: ${{ matrix.WITH_LLVM }} - WITH_BENCHMARKS_NONIUS: ${{ matrix.WITH_BENCHMARKS_NONIUS }} - WITH_SYMENGINE_RCP: ${{ matrix.WITH_SYMENGINE_RCP }} - TEST_IN_TREE: ${{ matrix.TEST_IN_TREE }} - WITH_SYMENGINE_THREAD_SAFE: ${{ matrix.WITH_SYMENGINE_THREAD_SAFE }} - WITH_PRIMESIEVE: ${{ matrix.WITH_PRIMESIEVE }} - INTEGER_CLASS: ${{ matrix.INTEGER_CLASS }} - WITH_ARB: ${{ matrix.WITH_ARB }} - WITH_PIRANHA: ${{ matrix.WITH_PIRANHA }} - WITH_GCC_6: ${{ matrix.WITH_GCC_6 }} - CONDA_ENV_FILE: ${{ matrix.CONDA_ENV_FILE }} - WITH_BFD: ${{ matrix.WITH_BFD }} - WITH_FLINT: ${{ matrix.WITH_FLINT }} - EXTRA_APT_REPOSITORY: ${{ matrix.EXTRA_APT_REPOSITORY }} - EXTRA_APT_PACKAGES: ${{ matrix.EXTRA_APT_PACKAGES }} - TEST_CLANG_FORMAT: ${{ matrix.TEST_CLANG_FORMAT }} - WITH_ECM: ${{ matrix.WITH_ECM }} - WITH_LATEST_GCC: ${{ matrix.WITH_LATEST_GCC }} - OS: ${{ matrix.OS }} - WITH_FLINT_DEV: ${{ matrix.WITH_FLINT_DEV }} - CC: ${{ matrix.CC }} - WITH_COVERAGE: ${{ matrix.WITH_COVERAGE }} - BUILD_TYPE: ${{ matrix.BUILD_TYPE }} - WITH_SANITIZE: ${{ matrix.WITH_SANITIZE }} - WITH_MPC: ${{ matrix.WITH_MPC }} - MAKEFLAGS: ${{ matrix.MAKEFLAGS }} - BUILD_SHARED_LIBS: ${{ matrix.BUILD_SHARED_LIBS }} - PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} - - - name: Deploy Documentation - if: ${{ (github.ref == 'refs/heads/main' && github.repository == 'Symengine/symengine.py') || (github.ref == 'refs/heads/master' && github.repository == 'Symengine/symengine.py')}} - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./genDocs diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f93c0227..00000000 --- a/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -# CMake -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake -install_manifest.txt -CTestTestfile.cmake -cython_test.cpp - -# Compiled Object Files, Static/Dynamic Libraries -*.so -*.a -*.o -*.out -*.exe -*.pyd -*.sln -*.vcxproj -*.filters -symengine/lib/symengine_wrapper.cpp -symengine/lib/symengine_wrapper.pyx -symengine/lib/symengine_wrapper.pxd - -# Config Files -symengine/lib/config.pxi - -# Python build files -build* -*__pycache__* -*.pyc -MANIFEST -*.egg-info -dist/ -.*cache/ -symengine.egg-info/ - -# Temp files -*~ -.eggs/ - -# Docs -genDocs/ -docs/_build/ -docs/source/ -symengine/lib/version_script_symengine_wrapper.txt diff --git a/.mailmap b/.mailmap deleted file mode 100644 index 11654a9b..00000000 --- a/.mailmap +++ /dev/null @@ -1,25 +0,0 @@ -# Prevent git from showing duplicate names with commands like "git shortlog" -# See the manpage of git-shortlog for details. -# The syntax is: -# Name that should be used Bad name -# -# You can skip Bad name if it is the same as the one that should be used, and is unique. -# -# This file is up-to-date if the command git log --format="%aN <%aE>" | sort -u -# gives no duplicates. - -Ondřej Čertík -Peter Brady -Isuru Fernando -Isuru Fernando -Alan Hu <31489167+alanlh@users.noreply.github.com> -Shivam Vats -Shikhar Jaiswal -Sumith Kulal -Sushant Hiray -Abhinav Agarwal -Nilay Pochhi -Björn Dahlgren -Richard Otis richardotis -Firat Bezir -Adrian Ostrowski <81568391+aostrowski-hbn@users.noreply.github.com> diff --git a/symengine/lib/__init__.py b/.nojekyll similarity index 100% rename from symengine/lib/__init__.py rename to .nojekyll diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 484d38be..00000000 --- a/AUTHORS +++ /dev/null @@ -1,41 +0,0 @@ -All people who contributed to symengine.py by sending at least a patch or more -(Note that this repository was a subfolder of symengine repo and early contributors -to the python bindings maybe listed in AUTHORS of symengine repo). -You can generate this file by: bin/update_authors.sh. - -Ondřej Čertík -Thilina Bandara Rathanyake -Isuru Fernando -Sushant Hiray -Peter Brady -Thilina Bandara Rathnayake -Shivam Vats -Sumith Kulal -Connor Behan -Ralf Stephan -Björn Dahlgren -Indrek Mandre -Abhinav Agarwal -Matt Wala -Shikhar Jaiswal -Nilay Pochhi -xoviat -Jean-Christophe Fillion-Robin -Moritz E. Beber -Alan Hu -Richard Otis -Erik Jansson Agnvall -Simon Stelter -Jialin Ma -Rikard Nordgren -Rohit Goswami -Matthew Treinish -Michał Górny -Garming Sam -Pieter Eendebak -Ayush Kumar -Christian Clauss -Moraxyc -Aaron Miller <78561124+aaron-skydio@users.noreply.github.com> -Firat Bezir -Adrian Ostrowski diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index e83c95b1..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12...4.0.0) - -if (POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) # needed for llvm >= 16 -endif () -if (POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) # allow user to set *_ROOT variables -endif() - -project(python_wrapper) - -set(CMAKE_PREFIX_PATH ${SymEngine_DIR} ${CMAKE_PREFIX_PATH}) - -include(GNUInstallDirs) - -find_package(SymEngine 0.14.0 REQUIRED CONFIG - PATH_SUFFIXES lib/cmake/symengine cmake/symengine CMake/) -message("SymEngine_DIR : " ${SymEngine_DIR}) -message("SymEngine Version : " ${SymEngine_VERSION}) -set(CMAKE_BUILD_TYPE ${SYMENGINE_BUILD_TYPE}) -set(CMAKE_CXX_FLAGS_RELEASE ${SYMENGINE_CXX_FLAGS_RELEASE}) -set(CMAKE_CXX_FLAGS_DEBUG ${SYMENGINE_CXX_FLAGS_DEBUG}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SYMENGINE_CXX_FLAGS}") -include_directories(${SYMENGINE_INCLUDE_DIRS}) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") -find_package(Python REQUIRED) -find_package(Cython REQUIRED) -include_directories(${PYTHON_INCLUDE_PATH}) - -if (MINGW AND ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DMS_WIN64") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DMS_WIN64") -endif() - -if (MINGW AND (CMAKE_BUILD_TYPE STREQUAL "Release")) - try_compile(CHECK_PYTHON_HYPOT "${CMAKE_CURRENT_BINARY_DIR}/" "${CMAKE_SOURCE_DIR}/cmake/check_python_hypot.cpp") - if (NOT ${CHECK_PYTHON_HYPOT}) - # include cmath before all headers - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -include cmath") - endif() -endif() - -include(CheckTypeSize) -check_type_size("long double" SYMENGINE_SIZEOF_LONG_DOUBLE) - -if (HAVE_SYMENGINE_LLVM AND SYMENGINE_SIZEOF_LONG_DOUBLE GREATER "8" AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") - set (HAVE_SYMENGINE_LLVM_LONG_DOUBLE True) -else () - set (HAVE_SYMENGINE_LLVM_LONG_DOUBLE False) -endif () - -foreach (PKG MPC MPFR PIRANHA FLINT LLVM) - if ("${HAVE_SYMENGINE_${PKG}}" STREQUAL "") - set(HAVE_SYMENGINE_${PKG} False) - endif() -endforeach() -option(SYMENGINE_INSTALL_PY_FILES "Install python files" ON) - -message("CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}") -message("CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}") -message("CMAKE_CXX_FLAGS : ${CMAKE_CXX_FLAGS}") -message("CMAKE_CXX_FLAGS_RELEASE : ${CMAKE_CXX_FLAGS_RELEASE}") -message("CMAKE_CXX_FLAGS_DEBUG : ${CMAKE_CXX_FLAGS_DEBUG}") -message("HAVE_SYMENGINE_MPFR : ${HAVE_SYMENGINE_MPFR}") -message("HAVE_SYMENGINE_MPC : ${HAVE_SYMENGINE_MPC}") -message("HAVE_SYMENGINE_PIRANHA : ${HAVE_SYMENGINE_PIRANHA}") -message("HAVE_SYMENGINE_FLINT : ${HAVE_SYMENGINE_FLINT}") -message("HAVE_SYMENGINE_LLVM : ${HAVE_SYMENGINE_LLVM}") -message("HAVE_SYMENGINE_LLVM_LONG_DOUBLE : ${HAVE_SYMENGINE_LLVM_LONG_DOUBLE}") -message("SYMENGINE_COPY_EXTENSION : ${SYMENGINE_COPY_EXTENSION}") - -message("Copying source of python wrappers into: ${CMAKE_CURRENT_BINARY_DIR}") -file(COPY symengine/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/symengine) - -add_subdirectory(symengine) diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 6472ae39..00000000 --- a/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2013-2015 SymPy Development Team - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index c5d457e2..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include CMakeLists.txt LICENSE README.md symengine_version.txt -recursive-include symengine *.cpp *.h *.hpp CMakeLists.txt *.in *.cmake *.pyx *.pxd *.py *.pxi -recursive-include cmake *.cpp *.in *.cmake *.pyx *.py *.txt diff --git a/README.md b/README.md deleted file mode 100644 index e13eb727..00000000 --- a/README.md +++ /dev/null @@ -1,118 +0,0 @@ -# SymEngine Python Wrappers - -Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), -a fast C++ symbolic manipulation library. - -[![Build Status](https://travis-ci.org/symengine/symengine.py.svg)](https://travis-ci.org/symengine/symengine.py) -[![Build status](https://ci.appveyor.com/api/projects/status/sl189l9ck3gd8qvk/branch/master?svg=true)](https://ci.appveyor.com/project/symengine/symengine-py/branch/master) - -## Installation - -### Pip - -See License section for information about wheels - -```bash -pip install symengine --user -``` - -### Conda package manager - -```bash -conda install python-symengine -c conda-forge -``` - -### Build from source - -Install prerequisites. - -```bash -CMake >= 2.8.12 -Python3 >= 3.8 -Cython >= 0.29.24 -SymEngine >= 0.7.0 -``` - -For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is -supported. The latest git master branch may not work as there may be breaking -changes in **SymEngine**. - -Python wrappers can be installed by, - -```bash -python setup.py install -``` - -Additional options to `setup.py` are: - -```bash -python setup.py install build_ext - --symengine-dir=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory - --compiler=mingw32|msvc|cygwin # Select the compiler for Windows - --generator=cmake-generator # CMake Generator - --build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC - --define="var1=value1;var2=value2" # Give options to CMake - --inplace # Build the extension in source tree -``` - -Standard options to `setup.py` like `--user`, `--prefix` can be used to -configure install location. NumPy is used if found by default, if you wish -to make your choice of NumPy use explicit: then add -e.g. `WITH_NUMPY=False` to `--define`. - -### Notes on Dependencies - -If you intend to evaluate floating-point expressions (using **lambdify**), -you should consider linking against **LLVM**. Many users might also benefit -from linking against **FLINT**, as it is now LGPL-licensed. - -In general, **sudo** is only required if you are installing to the default -prefix (`/usr/local`). We recommend specifying a custom prefix -(`--prefix=$HOME/.local`) to avoid requiring administrative privileges, -which most users can do without using **sudo**. - -If you're uncomfortable specifying the prefix manually, we suggest using -**Conda** or installing the pre-built wheels via **pip** instead of building -from source. - -## Verification - -You can verify the installation of **SymEngine** by using the provided code -snippet in this README. This snippet ensures that the installation works as -expected and that basic functionality is available. - -```python -from symengine import var -x, y, z = var('x y z') -e = (x + y + z)**2 -expanded_e = e.expand() -print(expanded_e) -``` -This will output: -```python -x**2 + y**2 + z**2 + 2*x*y + 2*x*z + 2*y*z -``` - -Note: The verification code provided above checks the functionality of -SymEngine. For additional verification specific to SymEngine, please refer to -the [official SymEngine Python bindings repository](https://github.com/symengine/symengine.py) -for further tests and examples. - -## License - -symengine.py is MIT licensed and uses several LGPL, BSD-3, and MIT licensed -libraries. - -Licenses for the dependencies of pip wheels are as follows: - -- pip wheels on Unix use **GMP** (LGPL-3.0-or-later), - **MPFR** (LGPL-3.0-or-later), **MPC** (LGPL-3.0-or-later), - **LLVM** (Apache-2.0), **zlib** (Zlib), **libxml2** (MIT), - **zstd** (BSD-3-Clause), and **symengine** (MIT AND BSD-3-Clause). -- pip wheels on Windows use **MPIR** (LGPL-3.0-or-later) instead of **GMP** - above and **pthreads-win32** (LGPL-3.0-or-later) additionally. -- **NumPy** (BSD-3-Clause) and **SymPy** (BSD-3-Clause) are optional - dependencies. -- Sources for these binary dependencies can be found on - [symengine-wheels](https://github.com/symengine/symengine-wheels/releases). - diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index ce1c487c..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,146 +0,0 @@ -version: '{build}' - -image: "Visual Studio 2019" - -environment: - global: - PLATFORMTOOLSET: "v140" - - matrix: - - BUILD_TYPE: "Release" - COMPILER: MSVC15 - PLATFORM: "Win32" - PYTHON_VERSION: 39 - CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - WITH_MPFR: yes - WITH_MPC: yes - - BUILD_TYPE: "Release" - COMPILER: MSVC15 - PLATFORM: "x64" - PYTHON_VERSION: 310-x64 - CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - WITH_MPFR: yes - WITH_MPC: yes - - BUILD_TYPE: "Release" - COMPILER: MSVC15 - PLATFORM: "x64" - PYTHON_VERSION: 312-x64 - CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - - BUILD_TYPE: "Release" - COMPILER: MSVC15 - PLATFORM: "x64" - PYTHON_VERSION: 39-x64 - WITH_SYMPY: no - CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - - BUILD_TYPE: "Release" - COMPILER: MSVC15 - PLATFORM: "x64" - PYTHON_VERSION: 311-x64 - WITH_NUMPY: no - CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - #- BUILD_TYPE: "Debug" - # COMPILER: MinGW-w64 - # PYTHON_VERSION: 39-x64 - # WITH_NUMPY: no - #- BUILD_TYPE: "Release" - # COMPILER: MinGW-w64 - # PYTHON_VERSION: 39-x64 - #- BUILD_TYPE: "Debug" - # COMPILER: MinGW-w64 - # PYTHON_VERSION: 39-x64 - # WITH_SYMPY: no - - BUILD_TYPE: "Release" - COMPILER: MSVC15 - PLATFORM: "x64" - PYTHON_VERSION: 310-x64 - CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - WITH_MPFR: yes - WITH_MPC: yes - WITH_LLVM: yes - -install: -- set PYTHON_SOURCE_DIR=%CD% -- git clone https://github.com/sympy/symengine symengine-cpp -- if [%PLATFORM%]==[Win32] set "CONDA_SUBDIR=win-32" - -- if [%COMPILER%]==[MSVC15] call %CONDA_INSTALL_LOCN%\Scripts\activate.bat -- if [%COMPILER%]==[MSVC15] set "CONDA_DEPS=mpir=3.0.0 vc=14" -- if [%COMPILER%]==[MSVC15] if [%WITH_MPFR%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpfr=3.1.5" -- if [%COMPILER%]==[MSVC15] if [%WITH_MPC%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpc=1.0.3" -- if [%COMPILER%]==[MSVC15] if [%WITH_LLVM%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% llvmdev=4.0" -- if [%COMPILER%]==[MSVC15] set "CONDA_DEPS=%CONDA_DEPS% -c conda-forge" -- if [%COMPILER%]==[MSVC15] if [%BUILD_TYPE%]==[Debug] set "CONDA_DEPS=%CONDA_DEPS% -c symengine/label/debug" -- if [%COMPILER%]==[MSVC15] conda create -n deps --yes %CONDA_DEPS% -- if [%COMPILER%]==[MSVC15] call conda activate deps -- if [%COMPILER%]==[MSVC15] echo %CONDA_PREFIX% -- if [%COMPILER%]==[MSVC15] echo %PATH% -- if [%COMPILER%]==[MSVC15] set "PATH=%PATH%;%CONDA_PREFIX%\\Library\\bin;%CONDA_PREFIX%" -- if [%COMPILER%]==[MSVC15] echo %PATH% - -- if [%COMPILER%]==[MinGW] set "PATH=C:\MinGW\bin;%PATH%" -- if [%COMPILER%]==[MinGW] mingw-get update -# workaround for https://github.com/appveyor/ci/issues/996 -- if [%COMPILER%]==[MinGW] mingw-get upgrade mingw32-libstdc++ -- if [%COMPILER%]==[MinGW] mingw-get install mingw32-gmp - -- if [%COMPILER%]==[MinGW-w64] set "PATH=C:\mingw64\bin;%PATH%" - -- rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe" - -- if [%COMPILER%]==[MinGW-w64] call symengine-cpp\bin\appveyor-download.cmd "https://raw.githubusercontent.com/symengine/dependencies/5cff7d1736877336cf9fb58267111beea4fa152f/x86_64-4.9.1-release-posix-seh-rt_v3-rev1.7z" -FileName mw64.7z -- if [%COMPILER%]==[MinGW-w64] 7z x -oC:\ mw64.7z > NUL -- if [%COMPILER%]==[MinGW-w64] call symengine-cpp\bin\appveyor-download.cmd "https://raw.githubusercontent.com/symengine/dependencies/5cff7d1736877336cf9fb58267111beea4fa152f/gmp-6.0.0-x86_64-w64-mingw32.7z" -FileName gmp.7z -- if [%COMPILER%]==[MinGW-w64] 7z x -oC:\mingw64 gmp.7z > NUL - -- if NOT [%COMPILER%]==[MSVC15] call symengine-cpp\bin\appveyor-download.cmd "https://raw.githubusercontent.com/symengine/dependencies/dcc10cce2133e2b57e61c5ced6120139bbcdfa20/python-libs-mingw32.7z" -FileName pylibs.7z -- if NOT [%COMPILER%]==[MSVC15] 7z x -aoa -oC:\ pylibs.7z > NUL - -- set "PATH=C:\Python%PYTHON_VERSION%;C:\Python%PYTHON_VERSION%\Scripts;%PATH%" -- echo %PATH% -- pip install nose pytest cython setuptools -- if NOT [%WITH_NUMPY%]==[no] pip install numpy -- if NOT [%WITH_SYMPY%]==[no] pip install sympy - -- set /p commit=out.data - data[:] = [x[0] + x[1] - x[4] + 36.252574322669, x[0] - x[2] + x[3] + 21.3219379611249, x[3] + x[5] - x[6] + 9.9011158998744, 2*x[3] + x[5] - x[7] + 18.190422234653, 3*x[3] + x[5] - x[8] + 24.8679190043357, 4*x[3] + x[5] - x[9] + 29.9336062089226, -x[10] + 5*x[3] + x[5] + 28.5520551531262, 2*x[0] + x[11] - 2*x[4] - 2*x[5] + 32.4401680272417, 3*x[1] - x[12] + x[5] + 34.9992934135095, 4*x[1] - x[13] + x[5] + 37.0716199972041, x[14+0] - x[14+1] + 2*x[14+10] + 2*x[14+11] - x[14+12] - 2*x[14+13] + x[14+2] + 2*x[14+5] + 2*x[14+6] + 2*x[14+7] + 2*x[14+8] + 2*x[14+9] - exp_(x[0]) + exp_(x[1]) - 2*exp_(x[10]) - 2*exp_(x[11]) + exp_(x[12]) + 2*exp_(x[13]) - exp_(x[2]) - 2*exp_(x[5]) - 2*exp_(x[6]) - 2*exp_(x[7]) - 2*exp_(x[8]) - 2*exp_(x[9]), -x[14+0] - x[14+1] - 15*x[14+10] - 2*x[14+11] - 3*x[14+12] - 4*x[14+13] - 4*x[14+2] - 3*x[14+3] - 2*x[14+4] - 3*x[14+6] - 6*x[14+7] - 9*x[14+8] - 12*x[14+9] + exp_(x[0]) + exp_(x[1]) + 15*exp_(x[10]) + 2*exp_(x[11]) + 3*exp_(x[12]) + 4*exp_(x[13]) + 4*exp_(x[2]) + 3*exp_(x[3]) + 2*exp_(x[4]) + 3*exp_(x[6]) + 6*exp_(x[7]) + 9*exp_(x[8]) + 12*exp_(x[9]), -5*x[14+10] - x[14+2] - x[14+3] - x[14+6] - 2*x[14+7] - 3*x[14+8] - 4*x[14+9] + 5*exp_(x[10]) + exp_(x[2]) + exp_(x[3]) + exp_(x[6]) + 2*exp_(x[7]) + 3*exp_(x[8]) + 4*exp_(x[9]), -x[14+1] - 2*x[14+11] - 3*x[14+12] - 4*x[14+13] - x[14+4] + exp_(x[1]) + 2*exp_(x[11]) + 3*exp_(x[12]) + 4*exp_(x[13]) + exp_(x[4]), -x[14+10] - 2*x[14+11] - x[14+12] - x[14+13] - x[14+5] - x[14+6] - x[14+7] - x[14+8] - x[14+9] + exp_(x[10]) + 2*exp_(x[11]) + exp_(x[12]) + exp_(x[13]) + exp_(x[5]) + exp_(x[6]) + exp_(x[7]) + exp_(x[8]) + exp_(x[9])] - return out diff --git a/benchmarks/expand1.py b/benchmarks/expand1.py deleted file mode 100644 index fb910b31..00000000 --- a/benchmarks/expand1.py +++ /dev/null @@ -1,10 +0,0 @@ -import sys -sys.path.append("..") -from timeit import default_timer as clock -from symengine import var -var("x y z w") -e = (x+y+z+w)**60 -t1 = clock() -g = e.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand1_sage.py b/benchmarks/expand1_sage.py deleted file mode 100644 index a7b14ede..00000000 --- a/benchmarks/expand1_sage.py +++ /dev/null @@ -1,8 +0,0 @@ -from timeit import default_timer as clock -from sage.all import var -var("x y z w") -e = (x+y+z+w)**60 -t1 = clock() -g = e.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand2.py b/benchmarks/expand2.py deleted file mode 100755 index 6c9d5197..00000000 --- a/benchmarks/expand2.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python - -import sys -sys.path.append("..") -import os -from timeit import default_timer as clock -if os.environ.get("USE_SYMENGINE"): - from symengine import var -else: - from sympy import var - -def run_benchmark(n): - var("x y z w") - e = (x + y + z + w)**n - f = e * (e + w) - t1 = clock() - g = f.expand() - t2 = clock() - print("%s ms" % (1000 * (t2 - t1))) - -if __name__ == '__main__': - if len(sys.argv) > 1: - n = int(sys.argv[1]) - else: - n = 15 - run_benchmark(n) diff --git a/benchmarks/expand2_sage.py b/benchmarks/expand2_sage.py deleted file mode 100644 index f29f55dd..00000000 --- a/benchmarks/expand2_sage.py +++ /dev/null @@ -1,10 +0,0 @@ -from timeit import default_timer as clock -from sage.all import var -var("x y z w") -e = (x+y+z+w)**15 -f = e*(e+w) -print(f) -t1 = clock() -g = f.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand2b_sage.sage b/benchmarks/expand2b_sage.sage deleted file mode 100644 index 66056b04..00000000 --- a/benchmarks/expand2b_sage.sage +++ /dev/null @@ -1,10 +0,0 @@ -from timeit import default_timer as clock -R. = QQ[] -# Let this expand first, we don't time it: -e = (x+y+z+w)**15 -# Time the actual multiplication of two long polynomials: -t1 = clock() -f = e*(e+w) -t2 = clock() -print "Total time:", t2-t1, "s" -print "Number of terms:", len(f.monomials()) diff --git a/benchmarks/expand2b_sympy.py b/benchmarks/expand2b_sympy.py deleted file mode 100644 index 43dcd77b..00000000 --- a/benchmarks/expand2b_sympy.py +++ /dev/null @@ -1,10 +0,0 @@ -from timeit import default_timer as clock -from sympy import ring, ZZ -R, x, y, z, w = ring("x y z w", ZZ) -e = (x+y+z+w)**15 -t1 = clock() -f = e*(e+w) -t2 = clock() -#print f -print("Total time:", t2-t1, "s") -print("number of terms:", len(f)) diff --git a/benchmarks/expand3.py b/benchmarks/expand3.py deleted file mode 100644 index 18f0a9cb..00000000 --- a/benchmarks/expand3.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys -sys.path.append("..") -from timeit import default_timer as clock -from symengine import var -var("x y z") -f = (x**y + y**z + z**x)**100 -print(f) -t1 = clock() -g = f.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand3_sage.py b/benchmarks/expand3_sage.py deleted file mode 100644 index 75872fa4..00000000 --- a/benchmarks/expand3_sage.py +++ /dev/null @@ -1,9 +0,0 @@ -from timeit import default_timer as clock -from sage.all import var -var("x y z") -f = (x**y + y**z + z**x)**100 -print(f) -t1 = clock() -g = f.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand4.py b/benchmarks/expand4.py deleted file mode 100644 index 1bcdc6e7..00000000 --- a/benchmarks/expand4.py +++ /dev/null @@ -1,12 +0,0 @@ -import sys -sys.path.append("..") -from timeit import default_timer as clock -from symengine import var -var("x") -e = 1 -for i in range(1, 351): - e *= (i+x)**3 -t1 = clock() -f = e.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand4_sage.py b/benchmarks/expand4_sage.py deleted file mode 100644 index 961f5d3b..00000000 --- a/benchmarks/expand4_sage.py +++ /dev/null @@ -1,13 +0,0 @@ -print("import...") -from timeit import default_timer as clock -from sage.all import var -var("x") -e = 1 -print("constructing expression...") -for i in range(1, 351): - e *= (i+x)**3 -print("running benchmark...") -t1 = clock() -f = e.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand5.py b/benchmarks/expand5.py deleted file mode 100644 index 25ab7e7a..00000000 --- a/benchmarks/expand5.py +++ /dev/null @@ -1,12 +0,0 @@ -import sys -sys.path.append("..") -from timeit import default_timer as clock -from symengine import var -var("x y z") -e = (x+y+z+1)**15 -f = e*(e+1) -print(f) -t1 = clock() -g = f.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand5_sage.py b/benchmarks/expand5_sage.py deleted file mode 100644 index 8fb7ab45..00000000 --- a/benchmarks/expand5_sage.py +++ /dev/null @@ -1,10 +0,0 @@ -from timeit import default_timer as clock -from sage.all import var -var("x y z") -e = (x+y+z+1)**15 -f = e*(e+1) -print(f) -t1 = clock() -g = f.expand() -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/expand6.py b/benchmarks/expand6.py deleted file mode 100755 index b78d833d..00000000 --- a/benchmarks/expand6.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python - -import sys -sys.path.append("..") -import os -from timeit import default_timer as clock -if os.environ.get("USE_SYMENGINE"): - from symengine import symbols, expand -else: - from sympy import symbols, expand - -def run_benchmark(n): - a0 = symbols("a0") - a1 = symbols("a1") - e = a0 + a1 - f = 0; - for i in range(2, n): - s = symbols("a%s" % i) - e = e + s - f = f + s - f = -f - t1 = clock() - e = expand(e**2) - e = e.xreplace({a0: f}) - e = expand(e) - t2 = clock() - print("%s ms" % (1000 * (t2 - t1))) - -if __name__ == '__main__': - if len(sys.argv) > 1: - n = int(sys.argv[1]) - else: - n = 100 - run_benchmark(n) diff --git a/benchmarks/expand6b.py b/benchmarks/expand6b.py deleted file mode 100755 index 16b571a3..00000000 --- a/benchmarks/expand6b.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python - -import sys -sys.path.append("..") -import os -from timeit import default_timer as clock -if os.environ.get("USE_SYMENGINE"): - from symengine import symbols, expand, sin -else: - from sympy import symbols, expand, sin - -def run_benchmark(n): - a0 = symbols("a0") - a1 = symbols("a1") - e = a0 + a1 - f = 0; - for i in range(2, n): - s = symbols("a%s" % i) - e = e + sin(s) - f = f + sin(s) - f = -f - t1 = clock() - e = expand(e**2) - e = e.xreplace({a0: f}) - e = expand(e) - t2 = clock() - print("%s ms" % (1000 * (t2 - t1))) - -if __name__ == '__main__': - if len(sys.argv) > 1: - n = int(sys.argv[1]) - else: - n = 100 - run_benchmark(n) diff --git a/benchmarks/expand7.py b/benchmarks/expand7.py deleted file mode 100755 index c09c2bd7..00000000 --- a/benchmarks/expand7.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python - -import sys -sys.path.append("..") -import os -from timeit import default_timer as clock -if os.environ.get("USE_SYMENGINE"): - from symengine import symbols, sqrt, expand -else: - from sympy import symbols, sqrt, expand - -def run_benchmark(n): - x, y = symbols("x y") - e = (1 + sqrt(3) * x + sqrt(5) * y) ** n - f = e * (e + sqrt(7)) - t1 = clock() - f = expand(f) - t2 = clock() - print("%s ms" % (1000 * (t2 - t1))) - -if __name__ == '__main__': - if len(sys.argv) > 1: - n = int(sys.argv[1]) - else: - n = 20 - run_benchmark(n) diff --git a/benchmarks/expr.txt b/benchmarks/expr.txt deleted file mode 100644 index a6e31ce2..00000000 --- a/benchmarks/expr.txt +++ /dev/null @@ -1 +0,0 @@ --WRrad*g*mfork*sin(q2(t)) - WRrad*g*mframe*sin(q2(t)) - WRrad*g*mwf*sin(q2(t)) - WRrad*g*mwr*sin(q2(t)) + forkcg1*g*mfork*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*sin(htangle + q4(t))*sin(q5(t)) - forkcg3*g*mfork*sin(htangle + q4(t))**2*sin(q5(t))*cos(q2(t)) - forklength*g*mwf*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*sin(htangle + q4(t))*sin(q5(t)) - forkoffset*g*mwf*sin(htangle + q4(t))**2*sin(q5(t))*cos(q2(t)) - framelength*g*mfork*sin(q2(t))*cos(htangle + q4(t)) - framelength*g*mwf*sin(q2(t))*cos(htangle + q4(t)) + g*mfork*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(-forkcg1*sin(htangle + q4(t))*cos(q5(t)) - forkcg3*cos(htangle + q4(t))) + g*mframe*(-framecg1*sin(htangle + q4(t)) - framecg3*cos(htangle + q4(t)))*sin(q2(t)) + g*mwf*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) + ((-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))*(-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))*(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2))/((-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2)*(WFrad**2*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))**2/((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad**2*sin(htangle + q4(t))**2*sin(q5(t))**2/((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))**2/(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2))) - (-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2))*(forkcg1*g*mfork*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) + forkcg1*g*mfork*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - forkcg3*g*mfork*sin(htangle + q4(t))*cos(q2(t))*cos(q5(t)) - forklength*g*mwf*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*g*mwf*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - forkoffset*g*mwf*sin(htangle + q4(t))*cos(q2(t))*cos(q5(t)) + framecg1*g*mframe*cos(htangle + q4(t))*cos(q2(t)) - framecg3*g*mframe*sin(htangle + q4(t))*cos(q2(t)) - framelength*g*mfork*sin(htangle + q4(t))*cos(q2(t)) - framelength*g*mwf*sin(htangle + q4(t))*cos(q2(t))) + ((-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))*(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2))/((((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2)*(WFrad**2*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))**2/((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad**2*sin(htangle + q4(t))**2*sin(q5(t))**2/((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))**2/(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2))) + (-(-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))*(-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))*(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2))/((-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2)*(WFrad**2*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))**2/((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad**2*sin(htangle + q4(t))**2*sin(q5(t))**2/((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - (-WFrad*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WFrad*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*sin(htangle + q4(t))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))**2/(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2))) + (-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(-(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))**2/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) + (-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t)))**2 + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))**2 + (-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t)))**2))*(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*cos(q5(t)) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t)) - framelength*sin(htangle + q4(t))*cos(q2(t)) - (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + (-forklength*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t)))*sin(q5(t)) - forklength*(-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*cos(q5(t)) + framelength*sin(htangle + q4(t))*sin(q2(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*sin(htangle + q4(t))*sin(q2(t)))*(framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t))) + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))*(-WFrad*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + WRrad - forklength*sin(htangle + q4(t))*sin(q5(t))**2 - forklength*sin(htangle + q4(t))*cos(q5(t))**2 + framelength*cos(htangle + q4(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*cos(q5(t)))*cos(htangle + q4(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2) - (((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))*(-WRrad*sin(q2(t)) - framelength*sin(q2(t))*cos(htangle + q4(t)) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t))) - (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q2(t))) + ((forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*sin(htangle + q4(t))*sin(q5(t)) + (WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*cos(q5(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*cos(htangle + q4(t)))*(WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t))) + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))*(WFrad/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - WRrad*cos(q2(t)) - framelength*cos(htangle + q4(t))*cos(q2(t)) + (forklength*sin(htangle + q4(t))*cos(q5(t)) - forkoffset*cos(htangle + q4(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*cos(htangle + q4(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*sin(htangle + q4(t))*sin(q5(t))) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q5(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*sin(htangle + q4(t))*sin(q5(t)))*sin(htangle + q4(t))*sin(q2(t))))/(((forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + (-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) - (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q2(t)))**2 + (WRrad*sin(q2(t)) + framelength*sin(q2(t))*cos(htangle + q4(t)) + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*sin(q5(t)) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*cos(htangle + q4(t)) + (-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*cos(q5(t)))**2 + (framelength*sin(htangle + q4(t))*sin(q2(t))**2 + framelength*sin(htangle + q4(t))*cos(q2(t))**2 + (forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(-sin(q2(t))*sin(q5(t))*cos(htangle + q4(t)) + cos(q2(t))*cos(q5(t))) + (-sin(q2(t))*cos(htangle + q4(t))*cos(q5(t)) - sin(q5(t))*cos(q2(t)))*(-WFrad*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) - forklength*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) + (-WFrad*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))/sqrt((-sin(q2(t))*cos(q5(t)) - sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + 1) + forkoffset*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))))*sin(htangle + q4(t))*sin(q2(t)))**2))*(forkcg1*g*mfork*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) - forkcg3*g*mfork*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t)) - forklength*g*mwf*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) - forkoffset*g*mwf*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))*sin(htangle + q4(t))*cos(q2(t)) + framecg1*g*mframe*sin(q2(t))*cos(htangle + q4(t))*cos(q2(t)) - framecg3*g*mframe*sin(htangle + q4(t))*sin(q2(t))*cos(q2(t)) + g*mfork*(-forkcg1*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkcg3*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t))) + g*mframe*(-framecg1*cos(htangle + q4(t))*cos(q2(t)) + framecg3*sin(htangle + q4(t))*cos(q2(t)))*sin(q2(t)) + g*mwf*(forklength*(-sin(q2(t))*sin(q5(t)) + cos(htangle + q4(t))*cos(q2(t))*cos(q5(t))) + forkoffset*sin(htangle + q4(t))*cos(q2(t)))*(sin(q2(t))*cos(q5(t)) + sin(q5(t))*cos(htangle + q4(t))*cos(q2(t)))) \ No newline at end of file diff --git a/benchmarks/heterogeneous_output_Lambdify.py b/benchmarks/heterogeneous_output_Lambdify.py deleted file mode 100644 index f54d7ab1..00000000 --- a/benchmarks/heterogeneous_output_Lambdify.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -import os -from time import clock -import numpy as np -import sympy as sp -from sympy.parsing.sympy_parser import parse_expr -from sympy.parsing.sympy_parser import standard_transformations -import symengine as se -import warnings - -src = os.path.join(os.path.dirname(__file__), '6_links_rhs.txt') -serial = open(src).read() -parsed = parse_expr(serial, transformations=standard_transformations) -vec = sp.Matrix(1, 14, parsed) -args = tuple(sorted(vec.free_symbols, key=lambda arg: arg.name)) -exprs = vec, vec.jacobian(args[:-14]) -inp = np.ones(len(args)) -assert inp.size == 26 - - -lmb_sp = sp.lambdify(args, exprs, modules=['math', 'sympy']) -lmb_se = se.Lambdify(args, *exprs) -lmb_se_llvm = se.Lambdify(args, *exprs, backend='llvm') - - -lmb_sp(*inp) -tim_sympy = clock() -for i in range(500): - v, m = lmb_sp(*inp) -tim_sympy = clock() - tim_sympy - -lmb_se(inp) -tim_se = clock() -for i in range(500): - v, m = lmb_se(inp) -tim_se = clock() - tim_se - - -lmb_se_llvm(inp) -tim_se_llvm = clock() -res_se_llvm = np.empty(len(exprs)) -for i in range(500): - v, m = lmb_se_llvm(inp) -tim_se_llvm = clock() - tim_se_llvm - - -print('SymEngine (lambda double) speed-up factor (higher is better) vs sympy: %12.5g' % - (tim_sympy/tim_se)) - - -print('symengine (LLVM) speed-up factor (higher is better) vs sympy: %12.5g' % - (tim_sympy/tim_se_llvm)) - -import itertools -from functools import reduce -from operator import mul - -def ManualLLVM(inputs, *outputs): - outputs_ravel = list(itertools.chain(*outputs)) - cb = se.Lambdify(inputs, outputs_ravel, backend="llvm") - def func(*args): - result = [] - n = np.empty(len(outputs_ravel)) - t = cb.unsafe_real(np.concatenate([arg.ravel() for arg in args]), n) - start = 0 - for output in outputs: - elems = reduce(mul, output.shape) - result.append(n[start:start+elems].reshape(output.shape)) - start += elems - return result - return func - -lmb_se_llvm_manual = ManualLLVM(args, *exprs) -lmb_se_llvm_manual(inp) -tim_se_llvm_manual = clock() -for i in range(500): - v, m = lmb_se_llvm_manual(inp) -tim_se_llvm_manual = clock() - tim_se_llvm_manual -print('symengine (ManualLLVM) speed-up factor (higher is better) vs sympy: %12.5g' % - (tim_sympy/tim_se_llvm_manual)) - -if tim_se_llvm_manual < tim_se_llvm: - warnings.warn("Cython code for Lambdify.__call__ is slow.") diff --git a/benchmarks/kane.py b/benchmarks/kane.py deleted file mode 100644 index 96d5fb66..00000000 --- a/benchmarks/kane.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys -sys.path.append("..") -from timeit import default_timer as clock -from symengine import var, sympify, function_symbol, Symbol -import sympy -s = open("expr.txt").read() -printr("Converting to SymPy...") -e = sympy.sympify(s) -print("Converting to SymEngine...") -ce = sympify(e) -print(" Done.") -print("SymPy subs:") -t1 = clock() -f = e.subs(sympy.Function("q5")(sympy.Symbol("t")), sympy.Symbol("sq5")) -t2 = clock() -print("Total time:", t2-t1, "s") -print("SymEngine subs:") -t1 = clock() -cf = ce.subs(function_symbol("q5", Symbol("t")), Symbol("sq5")) -t2 = clock() -print("Total time:", t2-t1, "s") - -print("SymPy diff:") -t1 = clock() -g = f.diff(sympy.Symbol("sq5")) -t2 = clock() -print("Total time:", t2-t1, "s") -print("SymEngine diff:") -t1 = clock() -cg = cf.diff(Symbol("sq5")) -t2 = clock() -print("Total time:", t2-t1, "s") diff --git a/benchmarks/kane_generate.py b/benchmarks/kane_generate.py deleted file mode 100644 index b3c81284..00000000 --- a/benchmarks/kane_generate.py +++ /dev/null @@ -1,304 +0,0 @@ -from sympy import evalf, symbols, zeros, pi, sin, cos, sqrt, acos, Matrix -from sympy.physics.mechanics import (ReferenceFrame, dynamicsymbols, inertia, - KanesMethod, RigidBody, Point, dot) -from sympy.utilities.pytest import slow - -def test_bicycle(): - # Code to get equations of motion for a bicycle modeled as in: - # J.P Meijaard, Jim M Papadopoulos, Andy Ruina and A.L Schwab. Linearized - # dynamics equations for the balance and steer of a bicycle: a benchmark - # and review. Proceedings of The Royal Society (2007) 463, 1955-1982 - # doi: 10.1098/rspa.2007.1857 - - # Note that this code has been crudely ported from Autolev, which is the - # reason for some of the unusual naming conventions. It was purposefully as - # similar as possible in order to aide debugging. - - # Declare Coordinates & Speeds - # Simple definitions for qdots - qd = u - # Speeds are: yaw frame ang. rate, roll frame ang. rate, rear wheel frame - # ang. rate (spinning motion), frame ang. rate (pitching motion), steering - # frame ang. rate, and front wheel ang. rate (spinning motion). - # Wheel positions are ignorable coordinates, so they are not introduced. - q1, q2, q4, q5 = dynamicsymbols('q1 q2 q4 q5') - q1d, q2d, q4d, q5d = dynamicsymbols('q1 q2 q4 q5', 1) - u1, u2, u3, u4, u5, u6 = dynamicsymbols('u1 u2 u3 u4 u5 u6') - u1d, u2d, u3d, u4d, u5d, u6d = dynamicsymbols('u1 u2 u3 u4 u5 u6', 1) - - # Declare System's Parameters - WFrad, WRrad, htangle, forkoffset = symbols('WFrad WRrad htangle forkoffset') - forklength, framelength, forkcg1 = symbols('forklength framelength forkcg1') - forkcg3, framecg1, framecg3, Iwr11 = symbols('forkcg3 framecg1 framecg3 Iwr11') - Iwr22, Iwf11, Iwf22, Iframe11 = symbols('Iwr22 Iwf11 Iwf22 Iframe11') - Iframe22, Iframe33, Iframe31, Ifork11 = symbols('Iframe22 Iframe33 Iframe31 Ifork11') - Ifork22, Ifork33, Ifork31, g = symbols('Ifork22 Ifork33 Ifork31 g') - mframe, mfork, mwf, mwr = symbols('mframe mfork mwf mwr') - - # Set up reference frames for the system - # N - inertial - # Y - yaw - # R - roll - # WR - rear wheel, rotation angle is ignorable coordinate so not oriented - # Frame - bicycle frame - # TempFrame - statically rotated frame for easier reference inertia definition - # Fork - bicycle fork - # TempFork - statically rotated frame for easier reference inertia definition - # WF - front wheel, again posses a ignorable coordinate - N = ReferenceFrame('N') - Y = N.orientnew('Y', 'Axis', [q1, N.z]) - R = Y.orientnew('R', 'Axis', [q2, Y.x]) - Frame = R.orientnew('Frame', 'Axis', [q4 + htangle, R.y]) - WR = ReferenceFrame('WR') - TempFrame = Frame.orientnew('TempFrame', 'Axis', [-htangle, Frame.y]) - Fork = Frame.orientnew('Fork', 'Axis', [q5, Frame.x]) - TempFork = Fork.orientnew('TempFork', 'Axis', [-htangle, Fork.y]) - WF = ReferenceFrame('WF') - - # Kinematics of the Bicycle First block of code is forming the positions of - # the relevant points - # rear wheel contact -> rear wheel mass center -> frame mass center + - # frame/fork connection -> fork mass center + front wheel mass center -> - # front wheel contact point - WR_cont = Point('WR_cont') - WR_mc = WR_cont.locatenew('WR_mc', WRrad * R.z) - Steer = WR_mc.locatenew('Steer', framelength * Frame.z) - Frame_mc = WR_mc.locatenew('Frame_mc', - framecg1 * Frame.x - + framecg3 * Frame.z) - Fork_mc = Steer.locatenew('Fork_mc', - forkcg1 * Fork.x - + forkcg3 * Fork.z) - WF_mc = Steer.locatenew('WF_mc', forklength * Fork.x + forkoffset * Fork.z) - WF_cont = WF_mc.locatenew('WF_cont', WFrad * (dot(Fork.y, Y.z) * Fork.y - - Y.z).normalize()) - - # Set the angular velocity of each frame. - # Angular accelerations end up being calculated automatically by - # differentiating the angular velocities when first needed. - # u1 is yaw rate - # u2 is roll rate - # u3 is rear wheel rate - # u4 is frame pitch rate - # u5 is fork steer rate - # u6 is front wheel rate - Y.set_ang_vel(N, u1 * Y.z) - R.set_ang_vel(Y, u2 * R.x) - WR.set_ang_vel(Frame, u3 * Frame.y) - Frame.set_ang_vel(R, u4 * Frame.y) - Fork.set_ang_vel(Frame, u5 * Fork.x) - WF.set_ang_vel(Fork, u6 * Fork.y) - - # Form the velocities of the previously defined points, using the 2 - point - # theorem (written out by hand here). Accelerations again are calculated - # automatically when first needed. - WR_cont.set_vel(N, 0) - WR_mc.v2pt_theory(WR_cont, N, WR) - Steer.v2pt_theory(WR_mc, N, Frame) - Frame_mc.v2pt_theory(WR_mc, N, Frame) - Fork_mc.v2pt_theory(Steer, N, Fork) - WF_mc.v2pt_theory(Steer, N, Fork) - WF_cont.v2pt_theory(WF_mc, N, WF) - - # Sets the inertias of each body. Uses the inertia frame to construct the - # inertia dyadics. Wheel inertias are only defined by principle moments of - # inertia, and are in fact constant in the frame and fork reference frames; - # it is for this reason that the orientations of the wheels does not need - # to be defined. The frame and fork inertias are defined in the 'Temp' - # frames which are fixed to the appropriate body frames; this is to allow - # easier input of the reference values of the benchmark paper. Note that - # due to slightly different orientations, the products of inertia need to - # have their signs flipped; this is done later when entering the numerical - # value. - - Frame_I = (inertia(TempFrame, Iframe11, Iframe22, Iframe33, 0, 0, Iframe31), Frame_mc) - Fork_I = (inertia(TempFork, Ifork11, Ifork22, Ifork33, 0, 0, Ifork31), Fork_mc) - WR_I = (inertia(Frame, Iwr11, Iwr22, Iwr11), WR_mc) - WF_I = (inertia(Fork, Iwf11, Iwf22, Iwf11), WF_mc) - - # Declaration of the RigidBody containers. :: - - BodyFrame = RigidBody('BodyFrame', Frame_mc, Frame, mframe, Frame_I) - BodyFork = RigidBody('BodyFork', Fork_mc, Fork, mfork, Fork_I) - BodyWR = RigidBody('BodyWR', WR_mc, WR, mwr, WR_I) - BodyWF = RigidBody('BodyWF', WF_mc, WF, mwf, WF_I) - - - # The kinematic differential equations; they are defined quite simply. Each - # entry in this list is equal to zero. - kd = [q1d - u1, q2d - u2, q4d - u4, q5d - u5] - - # The nonholonomic constraints are the velocity of the front wheel contact - # point dotted into the X, Y, and Z directions; the yaw frame is used as it - # is "closer" to the front wheel (1 less DCM connecting them). These - # constraints force the velocity of the front wheel contact point to be 0 - # in the inertial frame; the X and Y direction constraints enforce a - # "no-slip" condition, and the Z direction constraint forces the front - # wheel contact point to not move away from the ground frame, essentially - # replicating the holonomic constraint which does not allow the frame pitch - # to change in an invalid fashion. - - conlist_speed = [WF_cont.vel(N) & Y.x, WF_cont.vel(N) & Y.y, WF_cont.vel(N) & Y.z] - - # The holonomic constraint is that the position from the rear wheel contact - # point to the front wheel contact point when dotted into the - # normal-to-ground plane direction must be zero; effectively that the front - # and rear wheel contact points are always touching the ground plane. This - # is actually not part of the dynamic equations, but instead is necessary - # for the lineraization process. - - conlist_coord = [WF_cont.pos_from(WR_cont) & Y.z] - - # The force list; each body has the appropriate gravitational force applied - # at its mass center. - FL = [(Frame_mc, -mframe * g * Y.z), - (Fork_mc, -mfork * g * Y.z), - (WF_mc, -mwf * g * Y.z), - (WR_mc, -mwr * g * Y.z)] - BL = [BodyFrame, BodyFork, BodyWR, BodyWF] - - - # The N frame is the inertial frame, coordinates are supplied in the order - # of independent, dependent coordinates, as are the speeds. The kinematic - # differential equation are also entered here. Here the dependent speeds - # are specified, in the same order they were provided in earlier, along - # with the non-holonomic constraints. The dependent coordinate is also - # provided, with the holonomic constraint. Again, this is only provided - # for the linearization process. - - KM = KanesMethod(N, q_ind=[q1, q2, q5], - q_dependent=[q4], configuration_constraints=conlist_coord, - u_ind=[u2, u3, u5], - u_dependent=[u1, u4, u6], velocity_constraints=conlist_speed, - kd_eqs=kd) - (fr, frstar) = KM.kanes_equations(FL, BL) - - # This is the start of entering in the numerical values from the benchmark - # paper to validate the eigen values of the linearized equations from this - # model to the reference eigen values. Look at the aforementioned paper for - # more information. Some of these are intermediate values, used to - # transform values from the paper into the coordinate systems used in this - # model. - PaperRadRear = 0.3 - PaperRadFront = 0.35 - HTA = evalf.N(pi / 2 - pi / 10) - TrailPaper = 0.08 - rake = evalf.N(-(TrailPaper*sin(HTA)-(PaperRadFront*cos(HTA)))) - PaperWb = 1.02 - PaperFrameCgX = 0.3 - PaperFrameCgZ = 0.9 - PaperForkCgX = 0.9 - PaperForkCgZ = 0.7 - FrameLength = evalf.N(PaperWb*sin(HTA)-(rake-(PaperRadFront-PaperRadRear)*cos(HTA))) - FrameCGNorm = evalf.N((PaperFrameCgZ - PaperRadRear-(PaperFrameCgX/sin(HTA))*cos(HTA))*sin(HTA)) - FrameCGPar = evalf.N(PaperFrameCgX / sin(HTA) + (PaperFrameCgZ - PaperRadRear - PaperFrameCgX / sin(HTA) * cos(HTA)) * cos(HTA)) - tempa = evalf.N(PaperForkCgZ - PaperRadFront) - tempb = evalf.N(PaperWb-PaperForkCgX) - tempc = evalf.N(sqrt(tempa**2+tempb**2)) - PaperForkL = evalf.N(PaperWb*cos(HTA)-(PaperRadFront-PaperRadRear)*sin(HTA)) - ForkCGNorm = evalf.N(rake+(tempc * sin(pi/2-HTA-acos(tempa/tempc)))) - ForkCGPar = evalf.N(tempc * cos((pi/2-HTA)-acos(tempa/tempc))-PaperForkL) - - # Here is the final assembly of the numerical values. The symbol 'v' is the - # forward speed of the bicycle (a concept which only makes sense in the - # upright, static equilibrium case?). These are in a dictionary which will - # later be substituted in. Again the sign on the *product* of inertia - # values is flipped here, due to different orientations of coordinate - # systems. - v = symbols('v') - val_dict = {WFrad: PaperRadFront, - WRrad: PaperRadRear, - htangle: HTA, - forkoffset: rake, - forklength: PaperForkL, - framelength: FrameLength, - forkcg1: ForkCGPar, - forkcg3: ForkCGNorm, - framecg1: FrameCGNorm, - framecg3: FrameCGPar, - Iwr11: 0.0603, - Iwr22: 0.12, - Iwf11: 0.1405, - Iwf22: 0.28, - Ifork11: 0.05892, - Ifork22: 0.06, - Ifork33: 0.00708, - Ifork31: 0.00756, - Iframe11: 9.2, - Iframe22: 11, - Iframe33: 2.8, - Iframe31: -2.4, - mfork: 4, - mframe: 85, - mwf: 3, - mwr: 2, - g: 9.81, - q1: 0, - q2: 0, - q4: 0, - q5: 0, - u1: 0, - u2: 0, - u3: v / PaperRadRear, - u4: 0, - u5: 0, - u6: v / PaperRadFront} - - # Linearizes the forcing vector; the equations are set up as MM udot = - # forcing, where MM is the mass matrix, udot is the vector representing the - # time derivatives of the generalized speeds, and forcing is a vector which - # contains both external forcing terms and internal forcing terms, such as - # centripital or coriolis forces. This actually returns a matrix with as - # many rows as *total* coordinates and speeds, but only as many columns as - # independent coordinates and speeds. - - e = KM._fr[0] - #import symengine - #print "Converting to symengine..." - #f = symengine.sympify(e) - print("Saving to expr.txt") - s = str(e) - open("expr.txt", "w").write(s) - return - import IPython - IPython.embed() - forcing_lin = KM.linearize()[0] - - # As mentioned above, the size of the linearized forcing terms is expanded - # to include both q's and u's, so the mass matrix must have this done as - # well. This will likely be changed to be part of the linearized process, - # for future reference. - MM_full = KM.mass_matrix_full - - MM_full_s = MM_full.subs(val_dict) - forcing_lin_s = forcing_lin.subs(KM.kindiffdict()).subs(val_dict) - - - MM_full_s = MM_full_s.evalf() - forcing_lin_s = forcing_lin_s.evalf() - - # Finally, we construct an "A" matrix for the form xdot = A x (x being the - # state vector, although in this case, the sizes are a little off). The - # following line extracts only the minimum entries required for eigenvalue - # analysis, which correspond to rows and columns for lean, steer, lean - # rate, and steer rate. - Amat = MM_full_s.inv() * forcing_lin_s - A = Amat.extract([1, 2, 4, 6], [1, 2, 3, 5]) - - # Precomputed for comparison - Res = Matrix([[ 0, 0, 1.0, 0], - [ 0, 0, 0, 1.0], - [9.48977444677355, -0.891197738059089*v**2 - 0.571523173729245, -0.105522449805691*v, -0.330515398992311*v], - [11.7194768719633, -1.97171508499972*v**2 + 30.9087533932407, 3.67680523332152*v, -3.08486552743311*v]]) - - - # Actual eigenvalue comparison - for i in range(6): - # Pull out eigenvalues, put in a list - e_valsA = list(A.subs(v, i).eigenvals(rational=False).keys()) - e_valsR = list(Res.subs(v, i).eigenvals(rational=False).keys()) - # sort the list - e_valsA.sort() - e_valsR.sort() - # numerically compare eigenvalues - for i in range(4): - assert abs(e_valsA[i] - e_valsR[i]) < 1e-12 - -test_bicycle() diff --git a/benchmarks/legendre1.py b/benchmarks/legendre1.py deleted file mode 100644 index 6fa30739..00000000 --- a/benchmarks/legendre1.py +++ /dev/null @@ -1,28 +0,0 @@ -import sys -sys.path.append("..") -from timeit import default_timer as clock -from symengine import var, Integer - -def fact(n): - if n in [0, 1]: - return 1 - else: - return n*fact(n-1) - -def diff(e, x, n): - for i in range(n): - e = e.diff(x) - return e - -def legendre(n, x): - e = Integer(1)/(Integer(2)**n * fact(Integer(n))) * diff((x**2-1)**n, x, n) - return e.expand() - -var("x") -for n in range(10): - print(n, legendre(n, x)) - -t1 = clock() -e = legendre(500, x) -t2 = clock() -print("Total time for legendre(500, x):", t2-t1, "s") diff --git a/benchmarks/legendre1_sage.py b/benchmarks/legendre1_sage.py deleted file mode 100644 index 4cddc843..00000000 --- a/benchmarks/legendre1_sage.py +++ /dev/null @@ -1,28 +0,0 @@ -print("import...") -from timeit import default_timer as clock -from sage.all import var, Integer -print(" done.") - -def fact(n): - if n in [0, 1]: - return 1 - else: - return n*fact(n-1) - -def diff(e, x, n): - for i in range(n): - e = e.diff(x) - return e - -def legendre(n, x): - e = Integer(1)/(Integer(2)**n * fact(Integer(n))) * diff((x**2-1)**n, x, n) - return e.expand() - -var("x") -for n in range(10): - print(n, legendre(n, x)) - -t1 = clock() -e = legendre(500, x) -t2 = clock() -print("Total time for legendre(500, x):", t2-t1, "s") diff --git a/benchmarks/pydy_pendulum.py b/benchmarks/pydy_pendulum.py deleted file mode 100644 index 708aec87..00000000 --- a/benchmarks/pydy_pendulum.py +++ /dev/null @@ -1,26 +0,0 @@ -import os -import time -import sys -sys.path = ["../sympy", "../pydy", "../symengine.py"] + sys.path - -import sympy -import symengine -import pydy -from sympy.physics.mechanics.models import n_link_pendulum_on_cart - -print(sympy.__file__) -print(symengine.__file__) -print(pydy.__file__) - -if (len(sys.argv) > 1): - n = int(sys.argv[1]) -else: - n = 4 - -start = time.time() -sys = n_link_pendulum_on_cart(n, cart_force=False) -end = time.time() - -print("%s s" % (end-start)) - -#print(sys.eom_method.mass_matrix) diff --git a/benchmarks/symbench.py b/benchmarks/symbench.py deleted file mode 100755 index 999ea89b..00000000 --- a/benchmarks/symbench.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python - -""" -Benchmarks listed at http://wiki.sagemath.org/symbench can be run using this script -To run all benchmarks using symengine, sympy and sage, python symbench.py sympy sage -""" - -import sys -import subprocess - -benchmarks = ['R1', 'R2', 'R3', 'R5', 'S1', 'S2', 'S3', 'S3a'] -symengine_skip = [False, False, False, False, False, False, False, False] -sympy_skip = [False, False, False, False, False, False, False, True] -sage_skip = [False, False, False, False, False, False, False, False] - -args = sys.argv[1:] -sympy = False -sage = False -if "sympy" in sys.argv: - sympy = True -if "sage" in sys.argv: - sage = True -ws = "\t\t\t\t" - -for i in range(len(benchmarks)): - benchmark = benchmarks[i] - sys.stdout.write("Time for " + benchmark) - a = None - b = None - c = None - if not symengine_skip[i]: - a = subprocess.check_output(['python', 'symbench_def.py', benchmark]) - a = "\t SymEngine : " + a + " s" - sys.stdout.write(a or ws) - if sympy: - if not sympy_skip[i]: - b = subprocess.check_output(['python', 'symbench_def.py', 'sympy', benchmark]) - b = "\t SymPy : " + b + " s" - sys.stdout.write(b or ws) - if sage: - if not sage_skip[i]: - c = subprocess.check_output(['sage', 'symbench_sage.py', benchmark]) - c = "\t Sage : " + c + " s" - sys.stdout.write(c or ws) - print("") diff --git a/benchmarks/symbench_def.py b/benchmarks/symbench_def.py deleted file mode 100644 index 97de2c16..00000000 --- a/benchmarks/symbench_def.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env python - -""" -Benchmarks listed at http://wiki.sagemath.org/symbench can be run using this script -To run the benchmark in symengine, run python symbench.py -To run the benchmark in sympy, run python symbench.py sympy -""" - -from timeit import default_timer as clock -from random import random -import sys - -if "sympy" in sys.argv: - is_sympy = True - from sympy import sqrt, Integer, var, I, sin, cos -else : - is_sympy = False - from symengine import sqrt, Integer, var, I, sin, cos - -def R1(): - def f(z): - return sqrt(Integer(1)/3)*z**2 + I/3 - if (is_sympy): - t1 = clock() - g = f(f(f(f(f(f(f(f(f(f(I/2)))))))))).as_real_imag()[0] - t2 = clock() - else : - t1 = clock() - g = f(f(f(f(f(f(f(f(f(f(I/2)))))))))).expand() - t2 = clock() - return t2 - t1 - -def R2(): - def hermite(n,y): - if n == 1: return 2*y - if n == 0: return 1 - return (2*y*hermite(n-1,y) - 2*(n-1)*hermite(n-2,y)).expand() - t1 = clock() - hermite(15, var('y')) - t2 = clock() - return t2 - t1 - -def R3(): - var('x y z') - f = x+y+z - t1 = clock() - a = [bool(f==f) for _ in range(10)] - t2 = clock() - return t2 - t1 - -def R5(): - def blowup(L,n): - for i in range(n): - L.append( (L[i] + L[i+1]) * L[i+2] ) - def uniq(x): - v = list(set(x)) - return v - var('x y z') - L = [x,y,z] - blowup(L,8) - t1 = clock() - L = uniq(L) - t2 = clock() - return t2 - t1 - -def S1(): - var("x y z") - e = (x+y+z+1)**7 - f = e*(e+1) - t1 = clock() - f = f.expand() - t2 = clock() - return t2 - t1 - -def S2(): - var("x y z") - e = (x**sin(x) + y**cos(y) + z**(x + y))**100 - t1 = clock() - f = e.expand() - t2 = clock() - return t2 - t1 - -def S3(): - var("x y z") - e = (x**y + y**z + z**x)**50 - e = e.expand() - t1 = clock() - f = e.diff(x) - t2 = clock() - return t2 - t1 - -def S3a(): - var("x y z") - e = (x**y + y**z + z**x)**500 - e = e.expand() - t1 = clock() - f = e.diff(x) - t2 = clock() - return t2 - t1 - -sys.stdout.write("%15.9f" % locals()[sys.argv[-1]]()) diff --git a/benchmarks/symbench_sage.py b/benchmarks/symbench_sage.py deleted file mode 100755 index f1b4e96c..00000000 --- a/benchmarks/symbench_sage.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env sage - -""" -Benchmarks listed at http://wiki.sagemath.org/symbench can be run using this script -To run the benchmark in symengine, run python symbench.py -To run the benchmark in sympy, run python symbench.py sympy -""" - -from timeit import default_timer as clock -from sage.all import * - -def R1(): - def f(z): return sqrt(1/3)*z**2 + i/3 - t1 = clock() - a = real(f(f(f(f(f(f(f(f(f(f(I/2))))))))))) - t2 = clock() - return t2 - t1 - -def R2(): - def hermite(n,y): - if n == 1: return 2*y - if n == 0: return 1 - return expand(2*y*hermite(n-1,y) - 2*(n-1)*hermite(n-2,y)) - t1 = clock() - hermite(15,var('y')) - t2 = clock() - return t2 - t1 - -def R3(): - var('x,y,z') - f = x+y+z - t1 = clock() - a = [bool(f==f) for _ in range(10)] - t2 = clock() - return t2 - t1 - -def R5(): - def blowup(L,n): - for i in range(n): - L.append( (L[i] + L[i+1]) * L[i+2] ) - (x, y, z)=var('x,y,z') - L = [x, y, z] - blowup(L, 8) - t1 = clock() - L=uniq(L) - t2 = clock() - return t2 - t1 - -def S1(): - var('x,y,z') - f = (x+y+z+1)**7 - t1 = clock() - g = expand(f*(f+1)) - t2 = clock() - return t2 - t1 - -def S2(): - var('x,y,z') - t1 = clock() - a = expand((x**sin(x) + y**cos(y) - z**(x+y))**100) - t2 = clock() - return t2 - t1 - -def S3(): - var('x,y,z') - f = expand((x**y + y**z + z**x)**50) - t1 = clock() - g = f.diff(x) - t2 = clock() - return t2 - t1 - -def S3a(): - var('x,y,z') - f = expand((x**y + y**z + z**x)**500) - t1 = clock() - g = f.diff(x) - t2 = clock() - return t2 - t1 - -sys.stdout.write("%15.9f" % locals()[sys.argv[-1]]()) diff --git a/bin/install_travis.sh b/bin/install_travis.sh deleted file mode 100644 index f63a4747..00000000 --- a/bin/install_travis.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -# symengine's bin/install_travis.sh will install miniconda - -export conda_pkgs="python=${PYTHON_VERSION} pip pytest setuptools gmp mpfr" - -if [[ "${WITH_NUMPY}" != "no" ]]; then - export conda_pkgs="${conda_pkgs} numpy"; -fi - -if [[ "${WITH_SCIPY}" == "yes" ]]; then - export conda_pkgs="${conda_pkgs} scipy"; -fi - -if [[ "${WITH_DOCS}" == "yes" ]]; then - export conda_pkgs="${conda_pkgs} sphinx recommonmark"; -fi - -if [[ "${WITH_FLINT_PY}" == "yes" ]]; then - export conda_pkgs="${conda_pkgs} python-flint"; # python-flint affects sympy, see e.g. sympy/sympy#26645 -fi - -if [[ "${WITH_SAGE}" == "yes" ]]; then - # This is split to avoid the 10 minute limit - conda install -q sagelib=8.1 - conda clean --all - export conda_pkgs="${conda_pkgs} sage=8.1"; -fi - -conda install -q ${conda_pkgs} "cython>=0.29.24" - -if [[ "${WITH_SYMPY}" != "no" ]]; then - pip install sympy; -fi - -conda clean --all \ No newline at end of file diff --git a/bin/test_python.py b/bin/test_python.py deleted file mode 100644 index 98c337ab..00000000 --- a/bin/test_python.py +++ /dev/null @@ -1,18 +0,0 @@ -import os -TEST_SYMPY = os.getenv('TEST_SYMPY', False) - -import symengine -if not symengine.test(): - raise Exception('Tests failed') - -if TEST_SYMPY: - import sympy - from sympy.core.cache import clear_cache - import atexit - - atexit.register(clear_cache) - print('Testing SYMPY') - if not sympy.test('sympy/physics/mechanics'): - raise Exception('Tests failed') - if not sympy.test('sympy/liealgebras'): - raise Exception('Tests failed') diff --git a/bin/test_symengine_unix.sh b/bin/test_symengine_unix.sh deleted file mode 100644 index 0c62b7d1..00000000 --- a/bin/test_symengine_unix.sh +++ /dev/null @@ -1,22 +0,0 @@ -export PYTHON_SOURCE_DIR=`pwd` -export TEST_CPP="no" -export MAKEFLAGS="-j2" - -git clone https://github.com/symengine/symengine symengine-cpp -cd symengine-cpp -export SOURCE_DIR=`pwd` -git checkout `cat ../symengine_version.txt` -cd .. - -# Setup travis for C++ library -cd $SOURCE_DIR -source bin/test_symengine.sh - -# Setup travis for Python wrappers -cd $PYTHON_SOURCE_DIR -source bin/install_travis.sh - -# Build Python wrappers and test -cd $PYTHON_SOURCE_DIR -bin/test_travis.sh - diff --git a/bin/test_travis.sh b/bin/test_travis.sh deleted file mode 100755 index d83b27db..00000000 --- a/bin/test_travis.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# Exit on error -set -e -# Echo each command -set -x - -python setup.py sdist -mkdir dist-extract -cd dist-extract -tar -xvf ../dist/symengine-*.tar.gz -cd symengine-* - -# Build inplace so that nosetests can be run inside source directory -python3 setup.py install build_ext --inplace --symengine-dir=$our_install_dir - -# Test python wrappers -python3 -m pip install pytest -python3 -m pytest -s -v $PWD/symengine/tests/test_*.py -mkdir -p empty && cd empty -python3 $PYTHON_SOURCE_DIR/bin/test_python.py diff --git a/bin/trigger_feedstock.sh b/bin/trigger_feedstock.sh deleted file mode 100755 index d7fe21c6..00000000 --- a/bin/trigger_feedstock.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -set -x - -if [[ "${TRIGGER_FEEDSTOCK}" != "yes" ]]; then - exit 0; -fi -if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then - echo "Testing a pull request, feedstock is not triggered."; - exit 0; -fi -if [[ "${GH_TOKEN}" == "" ]]; then - echo "Testing a fork, feedstock is not triggered."; - exit 0; -fi - - -cd $PYTHON_SOURCE_DIR; -git clean -dfx; -export ver=`git describe --tags` -if [[ $ver == "v"* ]] -then - ver=${ver:1}; -fi - -export symengine_ver=`cat symengine_version.txt` -if [[ $symengine_ver == "v"* ]] -then - symengine_ver=${symengine_ver:1}; -fi - -export commit=`git rev-parse HEAD` - -git config --global user.name "Isuru Fernando" -git config --global user.email "isuruf@gmail.com" - -set +x -git clone "https://${GH_TOKEN}@github.com/symengine/python-symengine-feedstock.git" feedstock -q -set -x - -cd feedstock -if [[ "${TRAVIS_TAG}" != "" ]]; then - git checkout tagged -else - echo "Testing merge. Not triggering feedstock" - exit 0 - # git checkout dev -fi - -sed -ie '1,2d' recipe/meta.yaml -sed -i '1s/^/{% set version = "'${ver}'" %}\n/' recipe/meta.yaml -sed -i '1s/^/{% set commit = "'${commit}'" %}\n/' recipe/meta.yaml -sed -i 's/^ - symengine [0-9].*/ - symengine '${symengine_ver}'/' recipe/meta.yaml -git add recipe/meta.yaml -git commit -m "Update symengine version to ${ver}" -git push -q - diff --git a/cmake/FindCython.cmake b/cmake/FindCython.cmake deleted file mode 100644 index beac6c56..00000000 --- a/cmake/FindCython.cmake +++ /dev/null @@ -1,75 +0,0 @@ -# -# Cython -# - -# This finds the "cython" executable in your PATH, and then in some standard -# paths: - -find_program(CYTHON_BIN NAMES cython cython3 cython2) -SET(CYTHON_FLAGS --cplus --fast-fail -3) - -SET(Cython_FOUND FALSE) -IF (CYTHON_BIN) - # Try to run Cython, to make sure it works: - execute_process( - COMMAND ${CYTHON_BIN} ${CYTHON_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cython_test.pyx - RESULT_VARIABLE CYTHON_RESULT - OUTPUT_VARIABLE CYTHON_OUTPUT - ERROR_VARIABLE CYTHON_ERROR - ) - if (CYTHON_RESULT EQUAL 0) - # Only if cython exits with the return code 0, we know that all is ok: - SET(Cython_FOUND TRUE) - SET(Cython_Compilation_Failed FALSE) - else (CYTHON_RESULT EQUAL 0) - SET(Cython_Compilation_Failed TRUE) - endif (CYTHON_RESULT EQUAL 0) -ENDIF (CYTHON_BIN) - - -IF (Cython_FOUND) - IF (NOT Cython_FIND_QUIETLY) - MESSAGE(STATUS "Found CYTHON: ${CYTHON_BIN}") - ENDIF (NOT Cython_FIND_QUIETLY) -ELSE (Cython_FOUND) - IF (Cython_FIND_REQUIRED) - if(Cython_Compilation_Failed) - MESSAGE(STATUS "Found CYTHON: ${CYTHON_BIN}") - # On Win the testing of Cython does not return any accessible value, so the test is not carried out. - # Fresh Cython install was tested and works. - IF(NOT MSVC) - MESSAGE(FATAL_ERROR - "Your Cython version is too old. Please upgrade Cython." - "STDOUT: ${CYTHON_OUTPUT}" - "STDERROR: ${CYTHON_ERROR}" - ) - ENDIF(NOT MSVC) - else(Cython_Compilation_Failed) - MESSAGE(FATAL_ERROR "Could not find Cython. Please install Cython.") - endif(Cython_Compilation_Failed) - ENDIF (Cython_FIND_REQUIRED) -ENDIF (Cython_FOUND) - - -# This allows to link Cython files -# Examples: -# 1) to compile assembly.pyx to assembly.so: -# CYTHON_ADD_MODULE(assembly) -# 2) to compile assembly.pyx and something.cpp to assembly.so: -# CYTHON_ADD_MODULE(assembly something.cpp) - -if(NOT CYTHON_INCLUDE_DIRECTORIES) - set(CYTHON_INCLUDE_DIRECTORIES .) -endif(NOT CYTHON_INCLUDE_DIRECTORIES) - -# Cythonizes the .pyx files into .cpp file (but doesn't compile it) -macro(CYTHON_ADD_MODULE_PYX cpp_name pyx_name) - # Allow the user to specify dependencies as optional arguments - set(DEPENDS ${DEPENDS} ${ARGN}) - add_custom_command( - OUTPUT ${cpp_name} - COMMAND ${CYTHON_BIN} - ARGS ${CYTHON_FLAGS} -I ${CYTHON_INCLUDE_DIRECTORIES} -o ${cpp_name} ${pyx_name} - DEPENDS ${DEPENDS} ${pyx_name} - COMMENT "Cythonizing ${pyx_name}") -endmacro(CYTHON_ADD_MODULE_PYX) diff --git a/cmake/FindNumPy.cmake b/cmake/FindNumPy.cmake deleted file mode 100644 index 66bf7bf4..00000000 --- a/cmake/FindNumPy.cmake +++ /dev/null @@ -1,19 +0,0 @@ -execute_process( - COMMAND ${PYTHON_BIN} -c "import numpy; print(numpy.get_include())" - RESULT_VARIABLE NUMPY_FIND_RESULT - OUTPUT_VARIABLE NUMPY_FIND_OUTPUT - ERROR_VARIABLE NUMPY_FIND_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -if(NOT NUMPY_FIND_RESULT MATCHES 0) - set(NUMPY_FOUND FALSE) - message(STATUS "NumPy import failure:\n${NUMPY_FIND_ERROR}") -else() - find_path(NUMPY_INCLUDE_PATH numpy/arrayobject.h - HINTS "${NUMPY_FIND_OUTPUT}" NO_DEFAULT_PATH) - if(NUMPY_INCLUDE_PATH) - set(NUMPY_FOUND TRUE CACHE BOOL INTERNAL "NumPy found") - INCLUDE(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(NUMPY DEFAULT_MSG NUMPY_INCLUDE_PATH) - endif() -endif() diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake deleted file mode 100644 index c1f6c439..00000000 --- a/cmake/FindPython.cmake +++ /dev/null @@ -1,147 +0,0 @@ -set(PYTHON_BIN python CACHE STRING "Python executable name") - -execute_process( - COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['include'])" - OUTPUT_VARIABLE PYTHON_SYS_PATH - ) -string(STRIP ${PYTHON_SYS_PATH} PYTHON_SYS_PATH) -FIND_PATH(PYTHON_INCLUDE_PATH Python.h - PATHS ${PYTHON_SYS_PATH} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) -message(STATUS "Python include path: ${PYTHON_INCLUDE_PATH}") - -set(PYTHON_INSTALL_HEADER_PATH ${PYTHON_INCLUDE_PATH}/symengine - CACHE BOOL "Python install headers path") - -execute_process( - COMMAND ${PYTHON_BIN} -c "from sysconfig import get_config_var; print(get_config_var('LIBDIR'))" - OUTPUT_VARIABLE PYTHON_LIB_PATH - ) -string(STRIP ${PYTHON_LIB_PATH} PYTHON_LIB_PATH) - -execute_process( - COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)" - OUTPUT_VARIABLE PYTHON_PREFIX_PATH -) - -string(STRIP ${PYTHON_PREFIX_PATH} PYTHON_PREFIX_PATH) - -execute_process( - COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])" - OUTPUT_VARIABLE PYTHON_VERSION -) -string(STRIP ${PYTHON_VERSION} PYTHON_VERSION) -message(STATUS "Python version: ${PYTHON_VERSION}") - -string(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOTS ${PYTHON_VERSION}) - -execute_process( - COMMAND ${PYTHON_BIN} -c "import sysconfig;print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))" - OUTPUT_VARIABLE PY_GIL_DISABLED -) -string(STRIP ${PY_GIL_DISABLED} PY_GIL_DISABLED) - -if ("${PY_GIL_DISABLED}" STREQUAL "True") - set (PY_THREAD "t") -endif() - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - FIND_LIBRARY(PYTHON_LIBRARY NAMES - python${PYTHON_VERSION}${PY_THREAD} - python${PYTHON_VERSION}m - python${PYTHON_VERSION_WITHOUT_DOTS}${PY_THREAD} - PATHS ${PYTHON_LIB_PATH} ${PYTHON_PREFIX_PATH}/lib ${PYTHON_PREFIX_PATH}/libs - PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) -endif() - -execute_process( - COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['platlib'])" - OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp -) -string(STRIP ${PYTHON_INSTALL_PATH_tmp} PYTHON_INSTALL_PATH_tmp) -set(PYTHON_INSTALL_PATH ${PYTHON_INSTALL_PATH_tmp} - CACHE BOOL "Python install path") -message(STATUS "Python install path: ${PYTHON_INSTALL_PATH}") - -execute_process( - COMMAND ${PYTHON_BIN} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_suffix.py - OUTPUT_VARIABLE PYTHON_EXTENSION_SOABI_tmp -) -string(STRIP ${PYTHON_EXTENSION_SOABI_tmp} PYTHON_EXTENSION_SOABI_tmp) - -set(PYTHON_EXTENSION_SOABI ${PYTHON_EXTENSION_SOABI_tmp} - CACHE STRING "Suffix for python extensions") - -INCLUDE(FindPackageHandleStandardArgs) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Python DEFAULT_MSG PYTHON_LIBRARY PYTHON_INCLUDE_PATH PYTHON_INSTALL_PATH) -else () - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Python DEFAULT_MSG PYTHON_INCLUDE_PATH PYTHON_INSTALL_PATH) -endif () - - -# Links a Python extension module. -# -# The exact link flags are platform dependent and this macro makes it possible -# to write platform independent cmakefiles. All you have to do is to change -# this: -# -# add_library(simple_wrapper SHARED ${SRC}) # Linux only -# set_target_properties(simple_wrapper PROPERTIES PREFIX "") -# -# to this: -# -# add_python_library(simple_wrapper ${SRC}) # Platform independent -# -# Full example: -# -# set(SRC -# iso_c_utilities.f90 -# pde_pointers.f90 -# example1.f90 -# example2.f90 -# example_eigen.f90 -# simple.f90 -# simple_wrapper.c -# ) -# add_python_library(simple_wrapper ${SRC}) - -macro(ADD_PYTHON_LIBRARY name) - # When linking Python extension modules, a special care must be taken about - # the link flags, which are platform dependent: - IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - # on Mac, we need to use the "-bundle" gcc flag, which is what MODULE - # does: - add_library(${name} MODULE ${ARGN}) - # and "-undefined dynamic_lookup" link flags, that we need to add by hand: - set_property(TARGET ${name} APPEND_STRING PROPERTY - LINK_FLAGS " -undefined dynamic_lookup -Wl,-exported_symbol,_PyInit_${name}") - ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - # on Linux, we need to use the "-shared" gcc flag, which is what SHARED - # does: - set(PYTHON_EXTENSION_NAME ${name}) - add_library(${name} SHARED ${ARGN}) - configure_file(${CMAKE_SOURCE_DIR}/cmake/version_script.txt - ${CMAKE_CURRENT_BINARY_DIR}/version_script_${name}.txt @ONLY) - set_property(TARGET ${name} APPEND_STRING PROPERTY - LINK_FLAGS " \"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_script_${name}.txt\"") - ELSE() - add_library(${name} SHARED ${ARGN}) - ENDIF() - set_target_properties(${name} PROPERTIES PREFIX "") - set_target_properties(${name} PROPERTIES OUTPUT_NAME "${name}${PYTHON_EXTENSION_SOABI}") - IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - target_link_libraries(${name} ${PYTHON_LIBRARY}) - set_target_properties(${name} PROPERTIES SUFFIX ".pyd") - IF("${PY_GIL_DISABLED}" STREQUAL "True") - target_compile_definitions(${name} PRIVATE Py_GIL_DISABLED=1) - ENDIF() - ENDIF() - -endmacro(ADD_PYTHON_LIBRARY) diff --git a/cmake/check_python_hypot.cpp b/cmake/check_python_hypot.cpp deleted file mode 100644 index dab1400b..00000000 --- a/cmake/check_python_hypot.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// python header pyconfig.h defines hypot to be _hypot and therefore build might fail in MinGW -// http://stackoverflow.com/questions/10660524/error-building-boost-1-49-0-with-gcc-4-7-0 -// This file checks whether the build fail - -#include -#include - - diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx deleted file mode 100644 index e97be0b4..00000000 --- a/cmake/cython_test.pyx +++ /dev/null @@ -1,82 +0,0 @@ -# Test that libcpp module is present: -from libcpp.vector cimport vector -from libcpp.string cimport string - -# Test the math library: -from libc.math cimport sin, cos, atan2 - -# Test that templates work: -cdef vector[int] array2vector_int(a): - cdef vector[int] v - for i in range(len(a)): - v.push_back(a[i]) - return v - -# Test that bool support works -from libcpp cimport bool - -# Test that C++ support works - -cdef extern from "electrostatics.h": - - ctypedef double scalar - - cdef cppclass Function: - pass - - cdef cppclass MeshFunction(Function): - scalar get_pt_value(double x, double y) - - cdef cppclass Solution(MeshFunction): - void copy(Solution *s) - - cdef cppclass Electrostatics: - void set_mesh_str(char *mesh) - void set_initial_mesh_refinement(int init_ref_num) - void set_initial_poly_degree(int p) - void set_material_markers(vector[int] &mat_markers) - void set_permittivity_array(vector[double] &p_array) - void set_charge_density_array(vector[double] &cd_array) - void set_boundary_markers_value(vector[int] &bdy_markers_val) - void set_boundary_values(vector[double] &bc_val) - void set_boundary_markers_derivative(vector[int] &bdy_markers_der) - void set_boundary_derivatives(vector[double] &bc_der) - bool calculate(Solution* phi) - -cdef extern from "" namespace "SymEngine": - cdef enum ENull: - null - - cdef cppclass RCP[T]: - T& operator*() nogil except + - void reset() nogil except + - - cdef cppclass Ptr[T]: - T& operator*() nogil except + - - RCP[Symbol] rcp_static_cast_Symbol "SymEngine::rcp_static_cast"(const RCP[Basic] &b) nogil - RCP[Add] rcp_static_cast_Add "SymEngine::rcp_static_cast"(const RCP[Basic] &b) nogil - - -cdef extern from "" namespace "SymEngine": - cdef cppclass Basic: - string __str__() nogil except + - RCP[Basic] diff(const RCP[Symbol] &x) nogil except + - - bool eq(RCP[Basic] &a, RCP[Basic] &b) nogil except + - bool neq(RCP[Basic] &a, RCP[Basic] &b) nogil except + - - bool is_a_Add "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Mul "SymEngine::is_a"(const Basic &b) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass Symbol(Basic): - Symbol(string name) nogil - string get_name() nogil - -cdef extern from "" namespace "SymEngine": - cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) nogil except + - cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) nogil except + - - cdef cppclass Add(Basic): - void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) diff --git a/cmake/get_suffix.py b/cmake/get_suffix.py deleted file mode 100644 index 42470fce..00000000 --- a/cmake/get_suffix.py +++ /dev/null @@ -1,6 +0,0 @@ -from sysconfig import get_config_var -extsuffix = get_config_var('EXT_SUFFIX') -if extsuffix is None: - print("") -else: - print(extsuffix[0:].rsplit(".", 1)[0]) diff --git a/cmake/preprocess.py b/cmake/preprocess.py deleted file mode 100644 index a99d2489..00000000 --- a/cmake/preprocess.py +++ /dev/null @@ -1,38 +0,0 @@ -import sys - - -def main(input_name, output_name, replacements): - replacements = dict((item.split("=")[0], item.split("=")[1] == "True") for item in replacements) - with open(input_name, "r") as inp: - text = inp.readlines() - - new_text = [] - in_cond = [True] - nspaces = [0] - for i, line in enumerate(text): - if line.strip().startswith("IF"): - s = len(line) - len(line.lstrip()) - while s <= nspaces[-1] and len(in_cond) > 1: - in_cond = in_cond[:-1] - nspaces = nspaces[:-1] - - cond = line.lstrip()[3:-2] - in_cond.append(replacements[cond]) - nspaces.append(s) - elif line.strip().startswith("ELSE"): - in_cond[-1] = not in_cond[-1] and in_cond[-2] - - if len(line) > 1 and not line.strip().startswith(("IF", "ELSE")): - while len(in_cond) > 1 and (len(line) <= nspaces[-1] or not line.startswith(" "*nspaces[-1]) or line[nspaces[-1]] != " "): - in_cond = in_cond[:-1] - nspaces = nspaces[:-1] - if len(line) == 1: - new_text.append(line) - elif in_cond[-1] and not line.strip().startswith(("IF", "ELSE")): - new_text.append(line[4*(len(in_cond) - 1):]) - - with open(output_name, "w") as out: - out.writelines(new_text) - -if __name__ == "__main__": - main(sys.argv[1], sys.argv[2], sys.argv[3:]) diff --git a/cmake/version_script.txt b/cmake/version_script.txt deleted file mode 100644 index 0b24ad9f..00000000 --- a/cmake/version_script.txt +++ /dev/null @@ -1,4 +0,0 @@ -{ - global: PyInit_@PYTHON_EXTENSION_NAME@; - local: *; -}; diff --git a/docs/conf.py b/docs/conf.py deleted file mode 100644 index 8643d463..00000000 --- a/docs/conf.py +++ /dev/null @@ -1,90 +0,0 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - -import os -import sys - -sys.path.insert(0, os.path.abspath("..")) - -import symengine - -# -- Project information ----------------------------------------------------- - -project = 'symengine' -copyright = '2021, SymEngine development team ' -author = 'SymEngine development team ' - -# The full version, including alpha/beta/rc tags -release = symengine.__version__ - - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", # Consumes docstrings - "sphinx.ext.napoleon", # Allows for Google Style Docs - "sphinx.ext.viewcode", # Links to source code - "sphinx.ext.intersphinx", # Connects to other documentation - "sphinx.ext.todo", # Show TODO details - "sphinx.ext.imgconverter", # Handle svg images - "sphinx.ext.duration", # Shows times in the processing pipeline - "sphinx.ext.mathjax", # Need math support - "sphinx.ext.githubpages", # Puts the .nojekyll and CNAME files - "sphinxcontrib.apidoc", # Automatically sets up sphinx-apidoc - # "recommonmark", # Parses markdown - "m2r2", # Parses markdown in rst -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# API Doc settings -apidoc_module_dir = "../" -apidoc_output_dir = "source" -apidoc_excluded_paths = ["tests"] -apidoc_separate_modules = True - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = "sphinx_book_theme" -html_title = "Symengine Python Bindings" -# html_logo = "path/to/logo.png" -# html_favicon = "path/to/favicon.ico" -html_theme_options = { - "repository_url": "https://github.com/symengine/symengine.py", - "use_repository_button": True, - "use_issues_button": True, - "use_edit_page_button": True, - "path_to_docs": "docs", - "use_download_button": True, - "home_page_in_toc": True -} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 9a47bd0a..00000000 --- a/docs/index.rst +++ /dev/null @@ -1,22 +0,0 @@ -.. symengine documentation master file, created by - sphinx-quickstart on Tue Jan 26 09:42:30 2021. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Symengine Python API Documentation -=================================== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - source/modules - -.. mdinclude:: ../README.md - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/setup.py b/setup.py deleted file mode 100644 index 23d948ef..00000000 --- a/setup.py +++ /dev/null @@ -1,250 +0,0 @@ -from os import getenv, path, makedirs -import os -import subprocess -import sys -import platform - -# Make sure the system has the right Python version. -if sys.version_info[:2] < (3, 9): - print("SymEngine requires Python 3.9 or newer. " - "Python %d.%d detected" % sys.version_info[:2]) - sys.exit(-1) - -# use setuptools by default as per the official advice at: -# packaging.python.org/en/latest/current.html#packaging-tool-recommendations -use_setuptools = True -# set the environment variable USE_DISTUTILS=True to force the use of distutils -use_distutils = getenv('USE_DISTUTILS') -if use_distutils is not None: - if use_distutils.lower() == 'true': - use_setuptools = False - else: - print("Value {} for USE_DISTUTILS treated as False". - format(use_distutils)) - -if use_setuptools: - try: - from setuptools import setup - from setuptools.command.install import install as _install - from setuptools.command.build_ext import build_ext as _build_ext - except ImportError: - use_setuptools = False - else: - try: - from setuptools.command.build import build as _build - except ImportError: - from distutils.command.build import build as _build - -if not use_setuptools: - from distutils.core import setup - from distutils.command.install import install as _install - from distutils.command.build_ext import build_ext as _build_ext - from distutils.command.build import build as _build - -cmake_opts = [("PYTHON_BIN", sys.executable), - ("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes")] -cmake_generator = [None] -cmake_build_type = ["Release"] - - -def process_opts(opts): - return ['-D'+'='.join(o) for o in opts] - - -def get_build_dir(dist): - source_dir = path.dirname(path.realpath(__file__)) - build = dist.get_command_obj('build') - build_ext = dist.get_command_obj('build_ext') - return source_dir if build_ext.inplace else build.build_platlib - - -global_user_options = [ - ('symengine-dir=', None, - 'path to symengine installation or build directory'), - ('generator=', None, 'cmake build generator'), - ('build-type=', None, 'build type: Release or Debug'), - ('define=', 'D', - 'options to cmake :='), -] - -def _process_define(arg): - (defs, one), = getattr(arg, 'define', None) or [('', '1')] - assert one == '1' - defs = [df for df in defs.split(';') if df != ''] - return [(s.strip(), None) if '=' not in s else - tuple(ss.strip() for ss in s.split('=')) - for s in defs] - - -class BuildWithCmake(_build): - sub_commands = [('build_ext', None)] - - -class BuildExtWithCmake(_build_ext): - _build_opts = _build_ext.user_options - user_options = list(global_user_options) - user_options.extend(_build_opts) - - def initialize_options(self): - _build_ext.initialize_options(self) - self.define = None - self.symengine_dir = None - self.generator = None - self.build_type = "Release" - - def finalize_options(self): - _build_ext.finalize_options(self) - # The argument parsing will result in self.define being a string, but - # it has to be a list of 2-tuples. - # Multiple symbols can be separated with semi-colons. - self.define = _process_define(self) - cmake_opts.extend(self.define) - if self.symengine_dir: - cmake_opts.extend([('SymEngine_DIR', self.symengine_dir)]) - - if self.generator: - cmake_generator[0] = self.generator - - cmake_build_type[0] = self.build_type - - def cmake_build(self): - source_dir = path.dirname(path.realpath(__file__)) - build_dir = get_build_dir(self.distribution) - if not path.exists(build_dir): - makedirs(build_dir) - if build_dir != source_dir and path.exists("CMakeCache.txt"): - os.remove("CMakeCache.txt") - - cmake_cmd = ["cmake", source_dir, - "-DCMAKE_BUILD_TYPE=" + cmake_build_type[0], - "-DSYMENGINE_INSTALL_PY_FILES=ON", - ] - cmake_cmd.extend(process_opts(cmake_opts)) - if not path.exists(path.join(build_dir, "CMakeCache.txt")): - cmake_cmd.extend(self.get_generator()) - if subprocess.call(cmake_cmd, cwd=build_dir) != 0: - raise OSError("error calling cmake") - - if subprocess.call(["cmake", "--build", ".", - "--config", cmake_build_type[0]], - cwd=build_dir) != 0: - raise OSError("error building project") - - def get_generator(self): - if cmake_generator[0]: - return ["-G", cmake_generator[0]] - elif "CMAKE_GENERATOR" not in os.environ and platform.system() == "Windows": - compiler = str(self.compiler).lower() - if ("msys" in compiler): - return ["-G", "MSYS Makefiles"] - elif ("mingw" in compiler): - return ["-G", "MinGW Makefiles"] - else: - return ["-G", "NMake Makefiles"] - else: - return [] - - def run(self): - self.cmake_build() - _build_ext.run(self) - - -class InstallWithCmake(_install): - _install_opts = _install.user_options - user_options = list(global_user_options) - user_options.extend(_install_opts) - - def initialize_options(self): - _install.initialize_options(self) - self.define = None - self.symengine_dir = None - self.generator = None - self.build_type = "Release" - - def finalize_options(self): - _install.finalize_options(self) - # The argument parsing will result in self.define being a string, but - # it has to be a list of 2-tuples. - # Multiple symbols can be separated with semi-colons. - self.define = _process_define(self) - cmake_opts.extend(self.define) - cmake_build_type[0] = self.build_type - cmake_opts.extend([('PYTHON_INSTALL_PATH', path.join(os.getcwd(), self.install_platlib))]) - - def cmake_install(self): - source_dir = path.dirname(path.realpath(__file__)) - build_dir = get_build_dir(self.distribution) - cmake_cmd = ["cmake", source_dir] - cmake_cmd.extend(process_opts(cmake_opts)) - - # CMake has to be called here to update PYTHON_INSTALL_PATH - # if build and install were called separately by the user - if subprocess.call(cmake_cmd, cwd=build_dir) != 0: - raise OSError("error calling cmake") - - if subprocess.call(["cmake", "--build", ".", - "--config", cmake_build_type[0], - "--target", "install"], - cwd=build_dir) != 0: - raise OSError("error installing") - - import compileall - compileall.compile_dir(path.join(self.install_platlib, "symengine")) - - def run(self): - _install.run(self) - self.cmake_install() - -cmdclass={ - 'build': BuildWithCmake, - 'build_ext': BuildExtWithCmake, - 'install': InstallWithCmake, - } - -try: - from wheel.bdist_wheel import bdist_wheel - class BdistWheelWithCmake(bdist_wheel): - def finalize_options(self): - bdist_wheel.finalize_options(self) - self.root_is_pure = False - cmdclass["bdist_wheel"] = BdistWheelWithCmake -except ImportError: - pass - -long_description = ''' -SymEngine is a standalone fast C++ symbolic manipulation library. -Optional thin Python wrappers (SymEngine) allow easy usage from Python and -integration with SymPy and Sage. - -See https://github.com/symengine/symengine.py for information about License -and dependencies of wheels - -''' - -setup(name="symengine", - version="0.14.1", - description="Python library providing wrappers to SymEngine", - setup_requires=['cython>=0.29.24', 'setuptools'], - long_description=long_description, - author="SymEngine development team", - author_email="symengine@googlegroups.com", - license="MIT", - url="https://github.com/symengine/symengine.py", - python_requires='>=3.9,<4', - zip_safe=False, - packages=[], - cmdclass = cmdclass, - classifiers=[ - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Scientific/Engineering :: Physics', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', - ] - ) diff --git a/symengine/CMakeLists.txt b/symengine/CMakeLists.txt deleted file mode 100644 index bedec397..00000000 --- a/symengine/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -add_subdirectory(lib) - -if (SYMENGINE_INSTALL_PY_FILES) - add_subdirectory(tests) - set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine) - install( - FILES - __init__.py - functions.py - printing.py - sympy_compat.py - test_utilities.py - utilities.py - DESTINATION - ${PY_PATH} -) -endif () diff --git a/symengine/__init__.py b/symengine/__init__.py deleted file mode 100644 index e9545baf..00000000 --- a/symengine/__init__.py +++ /dev/null @@ -1,79 +0,0 @@ -import os -import sys - -if sys.platform == 'win32' \ - and 'SYMENGINE_PY_ADD_PATH_TO_SEARCH_DIRS' in os.environ: - for directory in os.environ['PATH'].split(';'): - if os.path.isdir(directory): - os.add_dll_directory(directory) - -del os, sys - -import symengine.lib.symengine_wrapper as wrapper - -from .lib.symengine_wrapper import ( - have_mpfr, have_mpc, have_flint, have_piranha, have_llvm, have_llvm_long_double, - I, E, pi, oo, zoo, nan, Symbol, Dummy, S, sympify, SympifyError, - Integer, Rational, Float, Number, RealNumber, RealDouble, ComplexDouble, - add, Add, Mul, Pow, function_symbol, - Max, Min, DenseMatrix, Matrix, - ImmutableMatrix, ImmutableDenseMatrix, MutableDenseMatrix, - MatrixBase, Basic, DictBasic, symarray, series, diff, zeros, - eye, diag, ones, Derivative, Subs, expand, has_symbol, - UndefFunction, Function, UnevaluatedExpr, latex, - have_numpy, true, false, Equality, Unequality, GreaterThan, - LessThan, StrictGreaterThan, StrictLessThan, Eq, Ne, Ge, Le, - Gt, Lt, And, Or, Not, Nand, Nor, Xor, Xnor, perfect_power, integer_nthroot, - isprime, sqrt_mod, Expr, cse, count_ops, ccode, Piecewise, Contains, Interval, FiniteSet, - linsolve, - FunctionSymbol, - golden_ratio as GoldenRatio, - catalan as Catalan, - eulergamma as EulerGamma, - unicode -) -from .utilities import var, symbols -from .functions import * -from .printing import init_printing - - -AppliedUndef = FunctionSymbol # an alias -EmptySet = wrapper.S.EmptySet -UniversalSet = wrapper.S.UniversalSet -Reals = wrapper.S.Reals -Integers = wrapper.S.Integers -Rationals = wrapper.S.Rationals - - -if have_mpfr: - from .lib.symengine_wrapper import RealMPFR - -if have_mpc: - from .lib.symengine_wrapper import ComplexMPC - -if have_numpy: - from .lib.symengine_wrapper import (Lambdify, LambdifyCSE) - - def lambdify(args, exprs, **kwargs): - return Lambdify(args, *exprs, **kwargs) -else: - def __getattr__(name): - if name == 'lambdify': - raise AttributeError("Cannot import numpy, which is required for `lambdify` to work") - raise AttributeError(f"module 'symengine' has no attribute '{name}'") - - -__version__ = "0.14.1" - - -# To not expose internals -del lib.symengine_wrapper -del lib -del wrapper - - -def test(): - import pytest - import os - return not pytest.cmdline.main( - [os.path.dirname(os.path.abspath(__file__))]) diff --git a/symengine/functions.py b/symengine/functions.py deleted file mode 100644 index a50af815..00000000 --- a/symengine/functions.py +++ /dev/null @@ -1,10 +0,0 @@ -from .lib.symengine_wrapper import (sin, cos, tan, cot, csc, sec, - asin, acos, atan, acot, acsc, asec, - sinh, cosh, tanh, coth, sech, csch, - asinh, acosh, atanh, acoth, asech, acsch, - gamma, log, atan2, sqrt, exp, Abs, - LambertW, zeta, dirichlet_eta, - KroneckerDelta, LeviCivita, erf, erfc, - lowergamma, uppergamma, loggamma, beta, - polygamma, sign, floor, ceiling, - conjugate, digamma, trigamma) diff --git a/symengine/lib/CMakeLists.txt b/symengine/lib/CMakeLists.txt deleted file mode 100644 index 7683d4aa..00000000 --- a/symengine/lib/CMakeLists.txt +++ /dev/null @@ -1,83 +0,0 @@ -set(SRC - ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.cpp - pywrapper.cpp - ) - -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd - ${PROJECT_SOURCE_DIR}/cmake/preprocess.py - COMMAND ${PYTHON_BIN} ${PROJECT_SOURCE_DIR}/cmake/preprocess.py - ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd - ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd - HAVE_SYMENGINE_MPFR=${HAVE_SYMENGINE_MPFR} - HAVE_SYMENGINE_MPC=${HAVE_SYMENGINE_MPC} - HAVE_SYMENGINE_PIRANHA=${HAVE_SYMENGINE_PIRANHA} - HAVE_SYMENGINE_FLINT=${HAVE_SYMENGINE_FLINT} - HAVE_SYMENGINE_LLVM=${HAVE_SYMENGINE_LLVM} - HAVE_SYMENGINE_LLVM_LONG_DOUBLE=${HAVE_SYMENGINE_LLVM_LONG_DOUBLE} - COMMENT "Preprocessing symengine_wrapper.in.pxd" -) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pyx - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pyx - ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd - ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd - ${PROJECT_SOURCE_DIR}/cmake/preprocess.py - COMMAND ${PYTHON_BIN} ${PROJECT_SOURCE_DIR}/cmake/preprocess.py - ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pyx - ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pyx - HAVE_SYMENGINE_MPFR=${HAVE_SYMENGINE_MPFR} - HAVE_SYMENGINE_MPC=${HAVE_SYMENGINE_MPC} - HAVE_SYMENGINE_PIRANHA=${HAVE_SYMENGINE_PIRANHA} - HAVE_SYMENGINE_FLINT=${HAVE_SYMENGINE_FLINT} - HAVE_SYMENGINE_LLVM=${HAVE_SYMENGINE_LLVM} - HAVE_SYMENGINE_LLVM_LONG_DOUBLE=${HAVE_SYMENGINE_LLVM_LONG_DOUBLE} - COMMENT "Preprocessing symengine_wrapper.in.pyx" -) - -cython_add_module_pyx(symengine_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pyx - ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd - ${CMAKE_CURRENT_SOURCE_DIR}/symengine.pxd) -add_python_library(symengine_wrapper ${SRC}) -target_link_libraries(symengine_wrapper ${SYMENGINE_LIBRARIES}) -if (CMAKE_CXX_COMPILER_ID MATCHES GNU|Clang) - # Must suppress strict aliasing for this file - set_source_files_properties( - symengine_wrapper.cpp - PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing -Wno-unused-function" - ) -endif() - -set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine/lib) -install(TARGETS symengine_wrapper - RUNTIME DESTINATION ${PY_PATH} - ARCHIVE DESTINATION ${PY_PATH} - LIBRARY DESTINATION ${PY_PATH} - ) -install(FILES - symengine.pxd - ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd - pywrapper.h - DESTINATION ${PY_PATH} - ) - -if (SYMENGINE_INSTALL_PY_FILES) - install(FILES __init__.py DESTINATION ${PY_PATH}) -endif () - -if (${SYMENGINE_COPY_EXTENSION}) - if ("${PYTHON_EXTENSION_SOABI}" MATCHES "ppc64le") - string(REPLACE "ppc64le" "powerpc64le" COPY_PYTHON_EXTENSION_SOABI "${PYTHON_EXTENSION_SOABI}") - endif () - if ("${PYTHON_EXTENSION_SOABI}" MATCHES "powerpc64le") - string(REPLACE "powerpc64le" "ppc64le" COPY_PYTHON_EXTENSION_SOABI "${PYTHON_EXTENSION_SOABI}") - endif () - message("${PYTHON_EXTENSION_SOABI} ${COPY_PYTHON_EXTENSION_SOABI}") - set(SOURCE_NAME "${PY_PATH}/symengine_wrapper${PYTHON_EXTENSION_SOABI}.so") - set(DEST_NAME "${PY_PATH}/symengine_wrapper${COPY_PYTHON_EXTENSION_SOABI}.so") - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${SOURCE_NAME} ${DEST_NAME})") -endif () diff --git a/symengine/lib/pywrapper.cpp b/symengine/lib/pywrapper.cpp deleted file mode 100644 index 5ab5e586..00000000 --- a/symengine/lib/pywrapper.cpp +++ /dev/null @@ -1,371 +0,0 @@ -#include "pywrapper.h" -#include - -#if PY_MAJOR_VERSION >= 3 -#define PyInt_FromLong PyLong_FromLong -#define PyNumber_Divide PyNumber_TrueDivide -#endif - -namespace SymEngine { - -// PyModule -PyModule::PyModule(PyObject* (*to_py)(const RCP), RCP (*from_py)(PyObject*), - RCP (*eval)(PyObject*, long), RCP (*diff)(PyObject*, RCP)) : - to_py_(to_py), from_py_(from_py), eval_(eval), diff_(diff) { - zero = PyInt_FromLong(0); - one = PyInt_FromLong(1); - minus_one = PyInt_FromLong(-1); -} - -PyModule::~PyModule(){ - Py_DECREF(zero); - Py_DECREF(one); - Py_DECREF(minus_one); -} - -// PyNumber -PyNumber::PyNumber(PyObject* pyobject, const RCP &pymodule) : - pyobject_(pyobject), pymodule_(pymodule) { -} - -hash_t PyNumber::__hash__() const { - return PyObject_Hash(pyobject_); -} - -bool PyNumber::__eq__(const Basic &o) const { - return is_a(o) and - PyObject_RichCompareBool(pyobject_, static_cast(o).get_py_object(), Py_EQ) == 1; -} - -int PyNumber::compare(const Basic &o) const { - SYMENGINE_ASSERT(is_a(o)) - PyObject* o1 = static_cast(o).get_py_object(); - if (PyObject_RichCompareBool(pyobject_, o1, Py_EQ) == 1) - return 0; - return PyObject_RichCompareBool(pyobject_, o1, Py_LT) == 1 ? -1 : 1; -} - -bool PyNumber::is_zero() const { - return PyObject_RichCompareBool(pyobject_, pymodule_->get_zero(), Py_EQ) == 1; -} -//! \return true if `1` -bool PyNumber::is_one() const { - return PyObject_RichCompareBool(pyobject_, pymodule_->get_one(), Py_EQ) == 1; -} -//! \return true if `-1` -bool PyNumber::is_minus_one() const { - return PyObject_RichCompareBool(pyobject_, pymodule_->get_minus_one(), Py_EQ) == 1; -} -//! \return true if negative -bool PyNumber::is_negative() const { - return PyObject_RichCompareBool(pyobject_, pymodule_->get_zero(), Py_LT) == 1; -} -//! \return true if positive -bool PyNumber::is_positive() const { - return PyObject_RichCompareBool(pyobject_, pymodule_->get_zero(), Py_GT) == 1; -} -//! \return true if complex -bool PyNumber::is_complex() const { - return false; -} - -//! Addition -RCP PyNumber::add(const Number &other) const { - PyObject *other_p, *result; - if (is_a(other)) { - other_p = static_cast(other).pyobject_; - result = PyNumber_Add(pyobject_, other_p); - } else { - other_p = pymodule_->to_py_(other.rcp_from_this_cast()); - result = PyNumber_Add(pyobject_, other_p); - Py_XDECREF(other_p); - } - return make_rcp(result, pymodule_); -} -//! Subtraction -RCP PyNumber::sub(const Number &other) const { - PyObject *other_p, *result; - if (is_a(other)) { - other_p = static_cast(other).pyobject_; - result = PyNumber_Subtract(pyobject_, other_p); - } else { - other_p = pymodule_->to_py_(other.rcp_from_this_cast()); - result = PyNumber_Subtract(pyobject_, other_p); - Py_XDECREF(other_p); - } - return make_rcp(result, pymodule_); -} -RCP PyNumber::rsub(const Number &other) const { - PyObject *other_p, *result; - if (is_a(other)) { - other_p = static_cast(other).pyobject_; - result = PyNumber_Subtract(other_p, pyobject_); - } else { - other_p = pymodule_->to_py_(other.rcp_from_this_cast()); - result = PyNumber_Subtract(other_p, pyobject_); - Py_XDECREF(other_p); - } - return make_rcp(result, pymodule_); -} -//! Multiplication -RCP PyNumber::mul(const Number &other) const { - PyObject *other_p, *result; - if (is_a(other)) { - other_p = static_cast(other).pyobject_; - result = PyNumber_Multiply(pyobject_, other_p); - } else { - other_p = pymodule_->to_py_(other.rcp_from_this_cast()); - result = PyNumber_Multiply(pyobject_, other_p); - Py_XDECREF(other_p); - } - return make_rcp(result, pymodule_); -} -//! Division -RCP PyNumber::div(const Number &other) const { - PyObject *other_p, *result; - if (is_a(other)) { - other_p = static_cast(other).pyobject_; - result = PyNumber_Divide(pyobject_, other_p); - } else { - other_p = pymodule_->to_py_(other.rcp_from_this_cast()); - result = PyNumber_Divide(pyobject_, other_p); - Py_XDECREF(other_p); - } - return make_rcp(result, pymodule_); -} -RCP PyNumber::rdiv(const Number &other) const { - PyObject *other_p, *result; - if (is_a(other)) { - other_p = static_cast(other).pyobject_; - result = PyNumber_Divide(pyobject_, other_p); - } else { - other_p = pymodule_->to_py_(other.rcp_from_this_cast()); - result = PyNumber_Divide(pyobject_, other_p); - Py_XDECREF(other_p); - } - return make_rcp(result, pymodule_); -} -//! Power -RCP PyNumber::pow(const Number &other) const { - PyObject *other_p, *result; - if (is_a(other)) { - other_p = static_cast(other).pyobject_; - result = PyNumber_Power(pyobject_, other_p, Py_None); - } else { - other_p = pymodule_->to_py_(other.rcp_from_this_cast()); - result = PyNumber_Power(pyobject_, other_p, Py_None); - Py_XDECREF(other_p); - } - return make_rcp(result, pymodule_); -} -RCP PyNumber::rpow(const Number &other) const { - PyObject *other_p, *result; - if (is_a(other)) { - other_p = static_cast(other).pyobject_; - result = PyNumber_Power(other_p, pyobject_, Py_None); - } else { - other_p = pymodule_->to_py_(other.rcp_from_this_cast()); - result = PyNumber_Power(other_p, pyobject_, Py_None); - Py_XDECREF(other_p); - } - return make_rcp(result, pymodule_); -} - -RCP PyNumber::eval(long bits) const { - return pymodule_->eval_(pyobject_, bits); -} - -std::string PyNumber::__str__() const { - Py_ssize_t size; - PyObject *pystr = PyObject_Str(pyobject_); - const char* data = PyUnicode_AsUTF8AndSize(pystr, &size); - std::string result = std::string(data, size); - Py_XDECREF(pystr); - return result; -} - -// PyFunctionClass - -PyFunctionClass::PyFunctionClass(PyObject *pyobject, std::string name, const RCP &pymodule) : - pyobject_{pyobject}, name_{name}, pymodule_{pymodule} { - -} - -PyObject* PyFunctionClass::call(const vec_basic &vec) const { - PyObject *tuple = PyTuple_New(vec.size()); - for (unsigned i = 0; i < vec.size(); i++) { - PyTuple_SetItem(tuple, i, pymodule_->to_py_(vec[i])); - } - PyObject* result = PyObject_CallObject(pyobject_, tuple); - Py_DECREF(tuple); - return result; -} - -bool PyFunctionClass::__eq__(const PyFunctionClass &x) const { - return PyObject_RichCompareBool(pyobject_, x.pyobject_, Py_EQ) == 1; -} - -int PyFunctionClass::compare(const PyFunctionClass &x) const { - if (__eq__(x)) return 0; - return PyObject_RichCompareBool(pyobject_, x.pyobject_, Py_LT) == 1 ? 1 : -1; -} - -hash_t PyFunctionClass::hash() const { - if (hash_ == 0) - hash_ = PyObject_Hash(pyobject_); - return hash_; -} - -// PyFunction -PyFunction::PyFunction(const vec_basic &vec, const RCP &pyfunc_class, - PyObject *pyobject) : FunctionWrapper(pyfunc_class->get_name(), std::move(vec)), - pyfunction_class_{pyfunc_class}, pyobject_{pyobject} { - -} - -PyFunction::~PyFunction() { - Py_DECREF(pyobject_); -} - -PyObject* PyFunction::get_py_object() const { - return pyobject_; -} - -RCP PyFunction::get_pyfunction_class() const { - return pyfunction_class_; -} - -RCP PyFunction::create(const vec_basic &x) const { - PyObject* pyobj = pyfunction_class_->call(x); - RCP result = pyfunction_class_->get_py_module()->from_py_(pyobj); - Py_XDECREF(pyobj); - return result; -} - -RCP PyFunction::eval(long bits) const { - return pyfunction_class_->get_py_module()->eval_(pyobject_, bits); -} - -RCP PyFunction::diff_impl(const RCP &s) const { - return pyfunction_class_->get_py_module()->diff_(pyobject_, s); -} - -hash_t PyFunction::__hash__() const { - return PyObject_Hash(pyobject_); -} - -bool PyFunction::__eq__(const Basic &o) const { - if (is_a(o) and - pyfunction_class_->__eq__(*static_cast(o).get_pyfunction_class()) and - unified_eq(get_vec(), static_cast(o).get_vec())) - return true; - return false; -} - -int PyFunction::compare(const Basic &o) const { - SYMENGINE_ASSERT(is_a(o)) - const PyFunction &s = static_cast(o); - int cmp = pyfunction_class_->compare(*s.get_pyfunction_class()); - if (cmp != 0) return cmp; - return unified_compare(get_vec(), s.get_vec()); -} - -inline PyObject* get_pickle_module() { - static PyObject *module = NULL; - if (module == NULL) { - module = PyImport_ImportModule("pickle"); - } - if (module == NULL) { - throw SymEngineException("error importing pickle module."); - } - return module; -} - -PyObject* pickle_loads(const std::string &pickle_str) { - PyObject *module = get_pickle_module(); - PyObject *pickle_bytes = PyBytes_FromStringAndSize(pickle_str.data(), pickle_str.size()); - PyObject *obj = PyObject_CallMethod(module, "loads", "O", pickle_bytes); - Py_XDECREF(pickle_bytes); - if (obj == NULL) { - throw SerializationError("error when loading pickled symbol subclass object"); - } - return obj; -} - -RCP load_basic(RCPBasicAwareInputArchive &ar, RCP &) -{ - bool is_pysymbol; - bool store_pickle; - std::string name; - ar(is_pysymbol); - ar(name); - if (is_pysymbol) { - std::string pickle_str; - ar(pickle_str); - ar(store_pickle); - PyObject *obj = pickle_loads(pickle_str); - RCP result = make_rcp(name, obj, store_pickle); - Py_XDECREF(obj); - return result; - } else { - return symbol(name); - } -} - -std::string pickle_dumps(const PyObject * obj) { - PyObject *module = get_pickle_module(); - PyObject *pickle_bytes = PyObject_CallMethod(module, "dumps", "O", obj); - if (pickle_bytes == NULL) { - throw SerializationError("error when pickling symbol subclass object"); - } - Py_ssize_t size; - char* buffer; - PyBytes_AsStringAndSize(pickle_bytes, &buffer, &size); - return std::string(buffer, size); -} - -void save_basic(RCPBasicAwareOutputArchive &ar, const Symbol &b) -{ - bool is_pysymbol = is_a_sub(b); - ar(is_pysymbol); - ar(b.__str__()); - if (is_pysymbol) { - RCP p = rcp_static_cast(b.rcp_from_this()); - PyObject *obj = p->get_py_object(); - std::string pickle_str = pickle_dumps(obj); - ar(pickle_str); - ar(p->store_pickle); - Py_XDECREF(obj); - } -} - -std::string wrapper_dumps(const Basic &x) -{ - std::ostringstream oss; - unsigned short major = SYMENGINE_MAJOR_VERSION; - unsigned short minor = SYMENGINE_MINOR_VERSION; - RCPBasicAwareOutputArchive{oss}(major, minor, - x.rcp_from_this()); - return oss.str(); -} - -RCP wrapper_loads(const std::string &serialized) -{ - unsigned short major, minor; - RCP obj; - std::istringstream iss(serialized); - RCPBasicAwareInputArchive iarchive{iss}; - iarchive(major, minor); - if (major != SYMENGINE_MAJOR_VERSION or minor != SYMENGINE_MINOR_VERSION) { - throw SerializationError(StreamFmt() - << "SymEngine-" << SYMENGINE_MAJOR_VERSION - << "." << SYMENGINE_MINOR_VERSION - << " was asked to deserialize an object " - << "created using SymEngine-" << major << "." - << minor << "."); - } - iarchive(obj); - return obj; -} - -} // SymEngine diff --git a/symengine/lib/pywrapper.h b/symengine/lib/pywrapper.h deleted file mode 100644 index 20a6dbee..00000000 --- a/symengine/lib/pywrapper.h +++ /dev/null @@ -1,220 +0,0 @@ -#ifndef SYMENGINE_PYWRAPPER_H -#define SYMENGINE_PYWRAPPER_H - -#include -#include -#include -#include - -namespace SymEngine { - -std::string pickle_dumps(const PyObject *); -PyObject* pickle_loads(const std::string &); - -/* - * PySymbol is a subclass of Symbol that keeps a reference to a Python object. - * When subclassing a Symbol from Python, the information stored in subclassed - * object is lost because all the arithmetic and function evaluations happen on - * the C++ side. The object returned by `(x + 1) - 1` is wrapped in the Python - * class Symbol and therefore the fact that `x` is a subclass of Symbol is lost. - * - * By subclassing in the C++ side and keeping a python object reference, the - * subclassed python object can be returned instead of wrapping in a Python - * class Symbol. - * - * TODO: Python object and C++ object both keep a reference to each other as one - * must be alive when the other is alive. This creates a cyclic reference and - * should be fixed. -*/ - -class PySymbol : public Symbol { -private: - PyObject* obj; - std::string bytes; -public: - const bool store_pickle; - PySymbol(const std::string& name, PyObject* obj, bool store_pickle) : - Symbol(name), obj(obj), store_pickle(store_pickle) { - if (store_pickle) { - bytes = pickle_dumps(obj); - } else { - Py_INCREF(obj); - } - } - PyObject* get_py_object() const { - if (store_pickle) { - return pickle_loads(bytes); - } else { - Py_INCREF(obj); - return obj; - } - } - virtual ~PySymbol() { - if (not store_pickle) { - // TODO: This is never called because of the cyclic reference. - Py_DECREF(obj); - } - } -}; - -/* - * This module provides classes to wrap Python objects defined in SymPy - * or Sage into SymEngine. - * - * PyModule is a python module (SymPy or Sage) that provides Python callbacks. - * These callback functions for conversion, evaluation and differentiation are - * defined in the Cython module `symengine_wrapper.pyx` and passed to C++. - * - * PyNumber is for numeric types where addition, subtraction, multiplication - * and division with other numeric types produce a numeric type. - * - * PyFunction is an instance of a function defined in SymPy or Sage and contains - * a PyFunctionClass instance which holds the callback functions needed for - * interaction with other SymEngine functions - * - * C++ Evaluation methods like eval_double, eval_mpfr calls the eval_ method to - * convert PyNumber and PyFunction to known SymEngine types. - */ - -//! Class to store the Python objects and Cython callback functions specific -// to a Python module. eg: SymPy or Sage -class PyModule : public EnableRCPFromThis { -public: - // Callback function to convert a SymEngine object to Python - PyObject* (*to_py_)(const RCP); - // Callback function to convert a Python object to SymEngine - RCP (*from_py_)(PyObject*); - // Callback function to evaluate a Python object to a bits number of - // precision and return a SymEngine Number - RCP (*eval_)(PyObject*, long bits); - // Callback function to differentiate a Python object with respect to - // a SymEngine symbol and get a SymEngine object - RCP (*diff_)(PyObject*, RCP); - // Common constants in Python - PyObject *one, *zero, *minus_one; -public: - PyModule(PyObject* (*)(const RCP x), RCP (*)(PyObject*), - RCP (*)(PyObject*, long), RCP (*)(PyObject*, RCP)); - ~PyModule(); - PyObject* get_zero() const { return zero; } - PyObject* get_one() const { return one; } - PyObject* get_minus_one() const { return minus_one; } -}; - -//! Python numeric types that do not have direct counterparts in SymEngine are -// wrapped using this method. Eg: Sage's real_mpfi. -// Arithmetic operations are done by calling Python/C API's PyNumber_* methods -// after converting SymEngine::Number to Python module type. Arithmetic -// operations always returns a PyNumber type. -class PyNumber : public NumberWrapper { -private: - //! Python reference to the object being wrapped - PyObject* pyobject_; - //! Python module that this object belongs to - RCP pymodule_; -public: - PyNumber(PyObject* pyobject, const RCP &pymodule); - ~PyNumber() { - Py_DECREF(pyobject_); - } - PyObject* get_py_object() const { return pyobject_; } - RCP get_py_module() const { return pymodule_; } - //! \return true if `0` - virtual bool is_zero() const; - //! \return true if `1` - virtual bool is_one() const; - //! \return true if `-1` - virtual bool is_minus_one() const; - //! \return true if negative - virtual bool is_negative() const; - //! \return true if positive - virtual bool is_positive() const; - //! \return true if complex - virtual bool is_complex() const; - //! return true if the number is an exact representation - // false if the number is an approximation - virtual bool is_exact() const { return true; }; - - //! Addition - virtual RCP add(const Number &other) const; - //! Subtraction - virtual RCP sub(const Number &other) const; - virtual RCP rsub(const Number &other) const; - //! Multiplication - virtual RCP mul(const Number &other) const; - //! Division - virtual RCP div(const Number &other) const; - virtual RCP rdiv(const Number &other) const; - //! Power - virtual RCP pow(const Number &other) const; - virtual RCP rpow(const Number &other) const; - - virtual RCP eval(long bits) const; - virtual std::string __str__() const; - virtual int compare(const Basic &o) const; - virtual bool __eq__(const Basic &o) const; - virtual hash_t __hash__() const; -}; - -/*! Class to represent the parent class for a PyFunction. Stores - * a python reference `pyobject_` to a python callable object. - * A PyFunction instance is an instance of the parent PyFunctionClass's - * `pyobject_`. - * */ -class PyFunctionClass : public EnableRCPFromThis { -private: - //! Callable python object to construct an instance of this class - PyObject *pyobject_; - //! Name of the function - std::string name_; - //! Hash of the python function - mutable hash_t hash_; - //! PyModule that this python function belongs to - RCP pymodule_; -public: - PyFunctionClass(PyObject *pyobject, std::string name, const RCP &pymodule); - PyObject* get_py_object() const { return pyobject_; } - RCP get_py_module() const { return pymodule_; } - std::string get_name() const { return name_; } - //! Create an instance of this class with arguments `vec`. - PyObject* call(const vec_basic &vec) const; - bool __eq__(const PyFunctionClass &x) const; - int compare(const PyFunctionClass &x) const; - hash_t hash() const; -}; - -/*! Class to represent the parent class for a PyFunction. Stores - * a python reference `pyobject_` to a python callable object. - * A PyFunction instance is an instance of the parent PyFunctionClass's - * `pyobject_`. - * */ -class PyFunction : public FunctionWrapper { -private: - RCP pyfunction_class_; - PyObject *pyobject_; -public: - PyFunction(const vec_basic &vec, const RCP &pyfunc_class, - PyObject *pyobject); - ~PyFunction(); - - PyObject *get_py_object() const; - RCP get_pyfunction_class() const; - //! Create an instance of similar type with arguments `x`. - virtual RCP create(const vec_basic &x) const; - //! Eval the number to bits precision and return a SymEngine::Number type - virtual RCP eval(long bits) const; - /*! Evaluate the derivative w.r.t. `x` by calling the callback function - * of the module that this function belongs to. - * */ - virtual RCP diff_impl(const RCP &x) const; - virtual int compare(const Basic &o) const; - virtual bool __eq__(const Basic &o) const; - virtual hash_t __hash__() const; -}; - -std::string wrapper_dumps(const Basic &x); -RCP wrapper_loads(const std::string &s); - -} - -#endif //SYMENGINE_PYWRAPPER_H diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd deleted file mode 100644 index 65b3456a..00000000 --- a/symengine/lib/symengine.pxd +++ /dev/null @@ -1,955 +0,0 @@ -from libcpp cimport bool -from libcpp.string cimport string -from libcpp.map cimport map -from libcpp.vector cimport vector -from cpython.ref cimport PyObject -from libcpp.pair cimport pair -from libcpp.set cimport set -from libcpp.unordered_map cimport unordered_map - -cdef extern from "" namespace "std": - # Cython's libcpp.set does not support multiset in 0.29.x - cdef cppclass multiset[T]: - cppclass iterator: - T& operator*() - iterator operator++() nogil - iterator operator--() nogil - bint operator==(iterator) nogil - bint operator!=(iterator) nogil - iterator begin() nogil - iterator end() nogil - iterator insert(T&) nogil - -cdef extern from 'symengine/mp_class.h' namespace "SymEngine": - ctypedef unsigned long mp_limb_t - ctypedef struct __mpz_struct: - pass - ctypedef struct __mpq_struct: - pass - ctypedef __mpz_struct mpz_t[1] - ctypedef __mpq_struct mpq_t[1] - - cdef cppclass integer_class: - integer_class() - integer_class(int i) - integer_class(integer_class) - integer_class(mpz_t) - integer_class(const string &s) except + - mpz_t get_mpz_t(integer_class &a) - const mpz_t get_mpz_t(const integer_class &a) - string mp_get_hex_str(const integer_class &a) - void mp_set_str(integer_class &a, const string &s) - cdef cppclass rational_class: - rational_class() - rational_class(mpq_t) - const mpq_t get_mpq_t(const rational_class &a) - -cdef extern from "" namespace "SymEngine": - cdef enum ENull: - null - - cdef cppclass RCP[T]: - T& operator*() nogil - # Not yet supported in Cython: -# RCP[T]& operator=(RCP[T] &r_ptr) nogil except + - void reset() nogil except + - - cdef cppclass Ptr[T]: - T& operator*() nogil except + - - void print_stack_on_segfault() nogil - -cdef extern from "" namespace "SymEngine": - ctypedef Basic const_Basic "const SymEngine::Basic" - # RCP[const_Basic] instead of RCP[const Basic] is because of https://github.com/cython/cython/issues/5478 - ctypedef RCP[const_Basic] rcp_const_basic "SymEngine::RCP" - #cdef cppclass rcp_const_basic "SymEngine::RCP": - # Basic& operator*() nogil - # void reset() nogil except + - # pass - # Cython has broken support for the following: - # ctypedef map[rcp_const_basic, rcp_const_basic] map_basic_basic - # So instead we replicate the map features we need here - cdef cppclass std_pair_short_rcp_const_basic "std::pair>": - short first - rcp_const_basic second - - cdef cppclass std_pair_rcp_const_basic_rcp_const_basic "std::pair, SymEngine::RCP>": - rcp_const_basic first - rcp_const_basic second - - cdef cppclass map_basic_basic: - map_basic_basic() except + - map_basic_basic(map_basic_basic&) except + - cppclass iterator: - std_pair_rcp_const_basic_rcp_const_basic& operator*() - iterator operator++() - iterator operator--() - bint operator==(iterator) - bint operator!=(iterator) - rcp_const_basic& operator[](rcp_const_basic&) - void clear() - bint empty() - size_t size() - void swap(map_basic_basic&) - iterator begin() - iterator end() - iterator find(rcp_const_basic&) - void erase(iterator, iterator) - void erase_it(iterator) - size_t erase(rcp_const_basic&) - pair[iterator, bint] insert(std_pair_rcp_const_basic_rcp_const_basic) except + - iterator insert(iterator, std_pair_rcp_const_basic_rcp_const_basic) except + - void insert(iterator, iterator) except + - - ctypedef vector[rcp_const_basic] vec_basic "SymEngine::vec_basic" - ctypedef vector[RCP[Symbol]] vec_sym "SymEngine::vec_sym" - ctypedef vector[RCP[Integer]] vec_integer "SymEngine::vec_integer" - ctypedef map[RCP[Integer], unsigned] map_integer_uint "SymEngine::map_integer_uint" - cdef struct RCPIntegerKeyLess - cdef struct RCPBasicKeyLess - ctypedef set[rcp_const_basic] set_basic "SymEngine::set_basic" - ctypedef multiset[rcp_const_basic] multiset_basic "SymEngine::multiset_basic" - - cdef cppclass Basic: - string __str__() nogil except + - unsigned int hash() nogil except + - vec_basic get_args() nogil - int __cmp__(const Basic &o) nogil - - ctypedef RCP[const Number] rcp_const_number "SymEngine::RCP" - ctypedef unordered_map[int, rcp_const_basic] umap_int_basic "SymEngine::umap_int_basic" - ctypedef unordered_map[int, rcp_const_basic].iterator umap_int_basic_iterator "SymEngine::umap_int_basic::iterator" - ctypedef unordered_map[rcp_const_basic, rcp_const_number] umap_basic_num "SymEngine::umap_basic_num" - ctypedef unordered_map[rcp_const_basic, rcp_const_number].iterator umap_basic_num_iterator "SymEngine::umap_basic_num::iterator" - ctypedef vector[pair[rcp_const_basic, rcp_const_basic]] vec_pair "SymEngine::vec_pair" - - bool eq(const Basic &a, const Basic &b) nogil except + - bool neq(const Basic &a, const Basic &b) nogil except + - - RCP[const Symbol] rcp_static_cast_Symbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const PySymbol] rcp_static_cast_PySymbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil except + - RCP[const Integer] rcp_static_cast_Integer "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Rational] rcp_static_cast_Rational "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Complex] rcp_static_cast_Complex "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Number] rcp_static_cast_Number "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Add] rcp_static_cast_Add "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Mul] rcp_static_cast_Mul "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Pow] rcp_static_cast_Pow "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const OneArgFunction] rcp_static_cast_OneArgFunction "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const FunctionSymbol] rcp_static_cast_FunctionSymbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const FunctionWrapper] rcp_static_cast_FunctionWrapper "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Abs] rcp_static_cast_Abs "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Max] rcp_static_cast_Max "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Min] rcp_static_cast_Min "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Infty] rcp_static_cast_Infty "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Gamma] rcp_static_cast_Gamma "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Derivative] rcp_static_cast_Derivative "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Subs] rcp_static_cast_Subs "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const RealDouble] rcp_static_cast_RealDouble "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const ComplexDouble] rcp_static_cast_ComplexDouble "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const ComplexBase] rcp_static_cast_ComplexBase "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const RealMPFR] rcp_static_cast_RealMPFR "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const ComplexMPC] rcp_static_cast_ComplexMPC "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Log] rcp_static_cast_Log "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const BooleanAtom] rcp_static_cast_BooleanAtom "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const PyNumber] rcp_static_cast_PyNumber "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const PyFunction] rcp_static_cast_PyFunction "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Boolean] rcp_static_cast_Boolean "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const Set] rcp_static_cast_Set "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - Ptr[RCP[Basic]] outArg(rcp_const_basic &arg) nogil - Ptr[RCP[Integer]] outArg_Integer "SymEngine::outArg>"(RCP[const Integer] &arg) nogil - - bool is_a[T] (const Basic &b) nogil - bool is_a_sub[T] (const Basic &b) nogil - rcp_const_basic expand(rcp_const_basic &o, bool deep) nogil except + - void as_numer_denom(rcp_const_basic &x, const Ptr[RCP[Basic]] &numer, const Ptr[RCP[Basic]] &denom) nogil - void as_real_imag(rcp_const_basic &x, const Ptr[RCP[Basic]] &real, const Ptr[RCP[Basic]] &imag) nogil - void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) nogil except + - -cdef extern from "" namespace "SymEngine": - rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) nogil except + - rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) nogil except + - rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) nogil except + - -cdef extern from "" namespace "SymEngine": - rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) nogil except + - -cdef extern from "" namespace "SymEngine": - cdef cppclass Symbol(Basic): - Symbol(string name) nogil - string get_name() nogil - cdef cppclass Dummy(Symbol): - pass - -cdef extern from "" namespace "SymEngine": - cdef cppclass Number(Basic): - bool is_positive() nogil - bool is_negative() nogil - bool is_zero() nogil - bool is_one() nogil - bool is_minus_one() nogil - bool is_complex() nogil - pass - cdef cppclass NumberWrapper(Basic): - pass - cdef tribool is_zero(const Basic &x) nogil - cdef tribool is_positive(const Basic &x) nogil - cdef tribool is_negative(const Basic &x) nogil - cdef tribool is_nonnegative(const Basic &x) nogil - cdef tribool is_nonpositive(const Basic &x) nogil - cdef tribool is_real(const Basic &x) nogil - -cdef extern from "pywrapper.h" namespace "SymEngine": - cdef cppclass PyNumber(NumberWrapper): - PyObject* get_py_object() - cdef cppclass PyModule: - pass - cdef cppclass PyFunctionClass: - PyObject* call(const vec_basic &vec) - cdef cppclass PyFunction: - PyObject* get_py_object() - -cdef extern from "pywrapper.h" namespace "SymEngine": - cdef cppclass PySymbol(Symbol): - PySymbol(string name, PyObject* pyobj, bool use_pickle) except + - PyObject* get_py_object() except + - - string wrapper_dumps(const Basic &x) nogil except + - rcp_const_basic wrapper_loads(const string &s) nogil except + - -cdef extern from "" namespace "SymEngine": - cdef cppclass Integer(Number): - Integer(int i) nogil - Integer(integer_class i) nogil - int compare(const Basic &o) nogil - integer_class as_integer_class() nogil - RCP[Number] divint(const Integer &other) nogil - cdef long mp_get_si(integer_class &i) nogil - cdef double mp_get_d(integer_class &i) nogil - cdef RCP[const Integer] integer(int i) nogil - cdef RCP[const Integer] integer(integer_class i) nogil - int i_nth_root(const Ptr[RCP[Integer]] &r, const Integer &a, unsigned long int n) nogil - bool perfect_square(const Integer &n) nogil - bool perfect_power(const Integer &n) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass Rational(Number): - rational_class as_rational_class() nogil - @staticmethod - RCP[const Number] from_two_ints(const long n, const long d) nogil - cdef double mp_get_d(rational_class &i) nogil - cdef RCP[const Number] from_mpq "SymEngine::Rational::from_mpq"(rational_class r) nogil - cdef void get_num_den(const Rational &rat, const Ptr[RCP[Integer]] &num, - const Ptr[RCP[Integer]] &den) nogil - cdef RCP[const Number] rational(long n, long d) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass ComplexBase(Number): - RCP[const Number] real_part() nogil - RCP[const Number] imaginary_part() nogil - cdef cppclass Complex(ComplexBase): - pass - -cdef extern from "" namespace "SymEngine": - cdef cppclass RealDouble(Number): - RealDouble(double x) nogil - double as_double() nogil - RCP[const RealDouble] real_double(double d) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass ComplexDouble(ComplexBase): - ComplexDouble(double complex x) nogil - double complex as_complex_double() nogil - RCP[const ComplexDouble] complex_double(double complex d) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass Constant(Basic): - Constant(string name) nogil - string get_name() nogil - rcp_const_basic I - rcp_const_basic E - rcp_const_basic pi - rcp_const_basic GoldenRatio - rcp_const_basic Catalan - rcp_const_basic EulerGamma - rcp_const_basic Inf - rcp_const_basic ComplexInf - rcp_const_basic Nan - -cdef extern from "" namespace "SymEngine": - cdef cppclass Infty(Number): - pass - -cdef extern from "" namespace "SymEngine": - cdef cppclass NaN(Number): - pass - -cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic add(rcp_const_basic &a, rcp_const_basic &b) nogil except + - cdef rcp_const_basic sub(rcp_const_basic &a, rcp_const_basic &b) nogil except + - cdef rcp_const_basic add(const vec_basic &a) nogil except + - - cdef cppclass Add(Basic): - void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) - RCP[const Number] get_coef() - const umap_basic_num &get_dict() - -cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic mul(rcp_const_basic &a, rcp_const_basic &b) nogil except + - cdef rcp_const_basic div(rcp_const_basic &a, rcp_const_basic &b) nogil except + - cdef rcp_const_basic neg(rcp_const_basic &a) nogil except + - cdef rcp_const_basic mul(const vec_basic &a) nogil except + - - cdef cppclass Mul(Basic): - void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) - RCP[const Number] get_coef() - const map_basic_basic &get_dict() - cdef RCP[const Mul] mul_from_dict "SymEngine::Mul::from_dict"(RCP[const Number] coef, map_basic_basic &d) nogil - -cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic pow(rcp_const_basic &a, rcp_const_basic &b) nogil except + - cdef rcp_const_basic sqrt(rcp_const_basic &x) nogil except + - cdef rcp_const_basic exp(rcp_const_basic &x) nogil except + - - cdef cppclass Pow(Basic): - rcp_const_basic get_base() nogil - rcp_const_basic get_exp() nogil - - -cdef extern from "" namespace "SymEngine": - # We need to specialize these for our classes: - rcp_const_basic make_rcp_Symbol "SymEngine::make_rcp"(string name) nogil - rcp_const_basic make_rcp_Dummy "SymEngine::make_rcp"() nogil - rcp_const_basic make_rcp_Dummy "SymEngine::make_rcp"(string name) nogil - rcp_const_basic make_rcp_PySymbol "SymEngine::make_rcp"(string name, PyObject * pyobj, bool use_pickle) except + - rcp_const_basic make_rcp_Constant "SymEngine::make_rcp"(string name) nogil - rcp_const_basic make_rcp_Infty "SymEngine::make_rcp"(RCP[const Number] i) nogil - rcp_const_basic make_rcp_NaN "SymEngine::make_rcp"() nogil - rcp_const_basic make_rcp_Integer "SymEngine::make_rcp"(int i) nogil - rcp_const_basic make_rcp_Integer "SymEngine::make_rcp"(integer_class i) nogil - rcp_const_basic make_rcp_Subs "SymEngine::make_rcp"(rcp_const_basic arg, const map_basic_basic &x) nogil - rcp_const_basic make_rcp_Derivative "SymEngine::make_rcp"(rcp_const_basic arg, const multiset_basic &x) nogil - rcp_const_basic make_rcp_FunctionWrapper "SymEngine::make_rcp"(void* obj, string name, string hash_, const vec_basic &arg, \ - void (*dec_ref)(void *), int (*comp)(void *, void *)) nogil - rcp_const_basic make_rcp_RealDouble "SymEngine::make_rcp"(double x) nogil - rcp_const_basic make_rcp_ComplexDouble "SymEngine::make_rcp"(double complex x) nogil - RCP[const PyModule] make_rcp_PyModule "SymEngine::make_rcp"(PyObject* (*) (rcp_const_basic x) except +, \ - rcp_const_basic (*)(PyObject*) except +, RCP[const Number] (*)(PyObject*, long bits) except +, - rcp_const_basic (*)(PyObject*, rcp_const_basic) except +) except + - rcp_const_basic make_rcp_PyNumber "SymEngine::make_rcp"(PyObject*, RCP[const PyModule] x) nogil - RCP[const PyFunctionClass] make_rcp_PyFunctionClass "SymEngine::make_rcp"(PyObject* pyobject, - string name, RCP[const PyModule] pymodule) nogil - rcp_const_basic make_rcp_PyFunction "SymEngine::make_rcp" (const vec_basic &vec, - RCP[const PyFunctionClass] pyfunc_class, const PyObject* pyobject) nogil - -cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic sin(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic cos(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic tan(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic cot(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic csc(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic sec(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic asin(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic acos(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic atan(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic acot(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic acsc(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic asec(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic sinh(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic cosh(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic tanh(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic coth(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic csch(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic sech(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic asinh(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic acosh(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic atanh(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic acoth(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic acsch(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic asech(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic function_symbol(string name, const vec_basic &arg) nogil except + - cdef rcp_const_basic abs(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic max(const vec_basic &arg) nogil except + - cdef rcp_const_basic min(const vec_basic &arg) nogil except + - cdef rcp_const_basic gamma(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic atan2(rcp_const_basic &num, rcp_const_basic &den) nogil except + - cdef rcp_const_basic lambertw(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic zeta(rcp_const_basic &s) nogil except + - cdef rcp_const_basic zeta(rcp_const_basic &s, rcp_const_basic &a) nogil except + - cdef rcp_const_basic dirichlet_eta(rcp_const_basic &s) nogil except + - cdef rcp_const_basic kronecker_delta(rcp_const_basic &i, rcp_const_basic &j) nogil except + - cdef rcp_const_basic levi_civita(const vec_basic &arg) nogil except + - cdef rcp_const_basic erf(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic erfc(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic lowergamma(rcp_const_basic &s, rcp_const_basic &x) nogil except + - cdef rcp_const_basic uppergamma(rcp_const_basic &s, rcp_const_basic &x) nogil except + - cdef rcp_const_basic loggamma(rcp_const_basic &arg) nogil except + - cdef rcp_const_basic beta(rcp_const_basic &x, rcp_const_basic &y) nogil except + - cdef rcp_const_basic polygamma(rcp_const_basic &n, rcp_const_basic &x) nogil except + - cdef rcp_const_basic digamma(rcp_const_basic &x) nogil except + - cdef rcp_const_basic trigamma(rcp_const_basic &x) nogil except + - cdef rcp_const_basic sign(rcp_const_basic &x) nogil except + - cdef rcp_const_basic floor(rcp_const_basic &x) nogil except + - cdef rcp_const_basic ceiling(rcp_const_basic &x) nogil except + - cdef rcp_const_basic conjugate(rcp_const_basic &x) nogil except + - cdef rcp_const_basic log(rcp_const_basic &x) nogil except + - cdef rcp_const_basic log(rcp_const_basic &x, rcp_const_basic &y) nogil except + - cdef rcp_const_basic unevaluated_expr(rcp_const_basic &x) nogil except + - - cdef cppclass Function(Basic): - pass - - cdef cppclass OneArgFunction(Function): - rcp_const_basic get_arg() nogil - - cdef cppclass TrigFunction(OneArgFunction): - pass - - cdef cppclass Sin(TrigFunction): - pass - - cdef cppclass Cos(TrigFunction): - pass - - cdef cppclass Tan(TrigFunction): - pass - - cdef cppclass Cot(TrigFunction): - pass - - cdef cppclass Csc(TrigFunction): - pass - - cdef cppclass Sec(TrigFunction): - pass - - cdef cppclass ASin(TrigFunction): - pass - - cdef cppclass ACos(TrigFunction): - pass - - cdef cppclass ATan(TrigFunction): - pass - - cdef cppclass ACot(TrigFunction): - pass - - cdef cppclass ACsc(TrigFunction): - pass - - cdef cppclass ASec(TrigFunction): - pass - - cdef cppclass HyperbolicFunction(OneArgFunction): - pass - - cdef cppclass Sinh(HyperbolicFunction): - pass - - cdef cppclass Cosh(HyperbolicFunction): - pass - - cdef cppclass Tanh(HyperbolicFunction): - pass - - cdef cppclass Coth(HyperbolicFunction): - pass - - cdef cppclass Csch(HyperbolicFunction): - pass - - cdef cppclass Sech(HyperbolicFunction): - pass - - cdef cppclass ASinh(HyperbolicFunction): - pass - - cdef cppclass ACosh(HyperbolicFunction): - pass - - cdef cppclass ATanh(HyperbolicFunction): - pass - - cdef cppclass ACoth(HyperbolicFunction): - pass - - cdef cppclass ACsch(HyperbolicFunction): - pass - - cdef cppclass ASech(HyperbolicFunction): - pass - - cdef cppclass FunctionSymbol(Function): - string get_name() nogil - - cdef cppclass FunctionWrapper(FunctionSymbol): - FunctionWrapper(void* obj, string name, string hash_, const vec_basic &arg, \ - void (*dec_ref)(void *), int (*comp)(void *, void *)) - void* get_object() - - cdef cppclass Derivative(Basic): - Derivative(const rcp_const_basic &arg, const vec_basic &x) nogil - rcp_const_basic get_arg() nogil - multiset_basic get_symbols() nogil - - cdef cppclass Subs(Basic): - Subs(const rcp_const_basic &arg, const map_basic_basic &x) nogil - rcp_const_basic get_arg() nogil - vec_basic get_variables() nogil - vec_basic get_point() nogil - - cdef cppclass Abs(OneArgFunction): - pass - - cdef cppclass Max(Function): - pass - - cdef cppclass Min(Function): - pass - - cdef cppclass Gamma(OneArgFunction): - pass - - cdef cppclass ATan2(Function): - pass - - cdef cppclass LambertW(OneArgFunction): - pass - - cdef cppclass Zeta(Function): - pass - - cdef cppclass Dirichlet_eta(OneArgFunction): - pass - - cdef cppclass KroneckerDelta(Function): - pass - - cdef cppclass LeviCivita(Function): - pass - - cdef cppclass Erf(OneArgFunction): - pass - - cdef cppclass Erfc(OneArgFunction): - pass - - cdef cppclass LowerGamma(Function): - pass - - cdef cppclass UpperGamma(Function): - pass - - cdef cppclass LogGamma(OneArgFunction): - pass - - cdef cppclass Beta(Function): - pass - - cdef cppclass PolyGamma(Function): - pass - - cdef cppclass Sign(OneArgFunction): - pass - - cdef cppclass Floor(OneArgFunction): - pass - - cdef cppclass Ceiling(OneArgFunction): - pass - - cdef cppclass Conjugate(OneArgFunction): - pass - - cdef cppclass UnevaluatedExpr(OneArgFunction): - pass - - cdef cppclass Log(Function): - pass - -cdef extern from "": - # These come from mpfr.h, but don't include mpfr.h to not break - # builds without mpfr - ctypedef struct __mpfr_struct: - pass - ctypedef __mpfr_struct mpfr_t[1] - ctypedef __mpfr_struct* mpfr_ptr - ctypedef const __mpfr_struct* mpfr_srcptr - ctypedef long mpfr_prec_t - ctypedef enum mpfr_rnd_t: - MPFR_RNDN - MPFR_RNDZ - MPFR_RNDU - MPFR_RNDD - MPFR_RNDA - MPFR_RNDF - MPFR_RNDNA - -cdef extern from "" namespace "SymEngine": - cdef cppclass mpfr_class: - mpfr_class() nogil - mpfr_class(mpfr_prec_t prec) nogil - mpfr_class(string s, mpfr_prec_t prec, unsigned base) nogil - mpfr_class(mpfr_t m) nogil - mpfr_ptr get_mpfr_t() nogil - - cdef cppclass RealMPFR(Number): - RealMPFR(mpfr_class) nogil - mpfr_class as_mpfr() nogil - mpfr_prec_t get_prec() nogil - - RCP[const RealMPFR] real_mpfr(mpfr_class t) nogil - -cdef extern from "": - # These come from mpc.h, but don't include mpc.h to not break - # builds without mpc - ctypedef struct __mpc_struct: - pass - ctypedef __mpc_struct mpc_t[1] - ctypedef __mpc_struct* mpc_ptr - ctypedef const __mpc_struct* mpc_srcptr - -cdef extern from "" namespace "SymEngine": - cdef cppclass mpc_class: - mpc_class() nogil - mpc_class(mpfr_prec_t prec) nogil - mpc_class(mpc_t m) nogil - mpc_ptr get_mpc_t() nogil - mpc_class(string s, mpfr_prec_t prec, unsigned base) nogil - - cdef cppclass ComplexMPC(ComplexBase): - ComplexMPC(mpc_class) nogil - mpc_class as_mpc() nogil - mpfr_prec_t get_prec() nogil - - RCP[const ComplexMPC] complex_mpc(mpc_class t) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass MatrixBase: - const unsigned nrows() nogil - const unsigned ncols() nogil - rcp_const_basic get(unsigned i, unsigned j) nogil - rcp_const_basic set(unsigned i, unsigned j, rcp_const_basic e) nogil - string __str__() nogil except + - bool eq(const MatrixBase &) nogil - rcp_const_basic det() nogil - void inv(MatrixBase &) - bool is_square() nogil - void add_matrix(const MatrixBase &other, MatrixBase &result) nogil - void mul_matrix(const MatrixBase &other, MatrixBase &result) nogil - void elementwise_mul_matrix(const MatrixBase &other, MatrixBase &result) nogil - void conjugate(MatrixBase &result) nogil - void conjugate_transpose(MatrixBase &result) nogil - void add_scalar(rcp_const_basic k, MatrixBase &result) nogil - void mul_scalar(rcp_const_basic k, MatrixBase &result) nogil - void transpose(MatrixBase &result) nogil - void submatrix(MatrixBase &result, - unsigned row_start, unsigned col_start, - unsigned row_end, unsigned col_end, - unsigned row_step, unsigned col_step) nogil - void LU(MatrixBase &L, MatrixBase &U) nogil - void LDL(MatrixBase &L, MatrixBase &D) nogil - void LU_solve(const MatrixBase &b, MatrixBase &x) nogil - void FFLU(MatrixBase &LU) nogil - void FFLDU(MatrixBase &L, MatrixBase &D, MatrixBase &U) nogil - void QR(MatrixBase &Q, MatrixBase &R) nogil - void cholesky(MatrixBase &L) nogil - - cdef cppclass DenseMatrix(MatrixBase): - DenseMatrix() - DenseMatrix(unsigned i, unsigned j) nogil - DenseMatrix(unsigned i, unsigned j, const vec_basic &v) nogil - void resize(unsigned i, unsigned j) nogil - void row_join(const DenseMatrix &B) nogil - void col_join(const DenseMatrix &B) nogil - void row_insert(const DenseMatrix &B, unsigned pos) nogil - void col_insert(const DenseMatrix &B, unsigned pos) nogil - void row_del(unsigned k) nogil - void col_del(unsigned k) nogil - rcp_const_basic trace() nogil - tribool is_zero() nogil - tribool is_real() nogil - tribool is_diagonal() nogil - tribool is_symmetric() nogil - tribool is_hermitian() nogil - tribool is_weakly_diagonally_dominant() nogil - tribool is_strictly_diagonally_dominant() nogil - tribool is_positive_definite() nogil - tribool is_negative_definite() nogil - - DenseMatrix* static_cast_DenseMatrix "static_cast"(const MatrixBase *a) - void inverse_FFLU "SymEngine::inverse_fraction_free_LU"(const DenseMatrix &A, - DenseMatrix &B) nogil except + - void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) nogil except + - void inverse_GJ "SymEngine::inverse_gauss_jordan"(const DenseMatrix &A, - DenseMatrix &B) nogil except + - void FFLU_solve "SymEngine::fraction_free_LU_solve"(const DenseMatrix &A, - const DenseMatrix &b, DenseMatrix &x) nogil except + - void FFGJ_solve "SymEngine::fraction_free_gauss_jordan_solve"(const DenseMatrix &A, - const DenseMatrix &b, DenseMatrix &x) nogil except + - void LDL_solve "SymEngine::LDL_solve"(const DenseMatrix &A, const DenseMatrix &b, - DenseMatrix &x) nogil except + - void jacobian "SymEngine::sjacobian"(const DenseMatrix &A, - const DenseMatrix &x, DenseMatrix &result) nogil except + - void diff "SymEngine::sdiff"(const DenseMatrix &A, - rcp_const_basic &x, DenseMatrix &result) nogil except + - void eye (DenseMatrix &A, int k) nogil - void diag(DenseMatrix &A, vec_basic &v, int k) nogil - void ones(DenseMatrix &A) nogil - void zeros(DenseMatrix &A) nogil - void row_exchange_dense(DenseMatrix &A, unsigned i, unsigned j) nogil - void row_mul_scalar_dense(DenseMatrix &A, unsigned i, rcp_const_basic &c) nogil - void row_add_row_dense(DenseMatrix &A, unsigned i, unsigned j, rcp_const_basic &c) nogil - void column_exchange_dense(DenseMatrix &A, unsigned i, unsigned j) nogil - void dot(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C) nogil - void cross(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C) nogil - -cdef extern from "": - void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[pair[int, int]] &P) nogil except + - -cdef extern from "" namespace "SymEngine": - int probab_prime_p(const Integer &a, int reps) - RCP[const Integer] nextprime (const Integer &a) nogil - RCP[const Integer] gcd(const Integer &a, const Integer &b) nogil - RCP[const Integer] lcm(const Integer &a, const Integer &b) nogil - void gcd_ext(const Ptr[RCP[Integer]] &g, const Ptr[RCP[Integer]] &s, - const Ptr[RCP[Integer]] &t, const Integer &a, const Integer &b) nogil - RCP[const Integer] mod "SymEngine::mod_f"(const Integer &n, const Integer &d) nogil except + - RCP[const Integer] quotient "SymEngine::quotient_f"(const Integer &n, const Integer &d) nogil except + - void quotient_mod "SymEngine::quotient_mod_f"(const Ptr[RCP[Integer]] &q, const Ptr[RCP[Integer]] &mod, - const Integer &n, const Integer &d) nogil except + - int mod_inverse(const Ptr[RCP[Integer]] &b, const Integer &a, - const Integer &m) nogil - bool crt(const Ptr[RCP[Integer]] &R, const vec_integer &rem, - const vec_integer &mod) nogil - RCP[const Integer] fibonacci(unsigned long n) nogil - void fibonacci2(const Ptr[RCP[Integer]] &g, const Ptr[RCP[Integer]] &s, - unsigned long n) nogil - RCP[const Integer] lucas(unsigned long n) nogil - void lucas2(const Ptr[RCP[Integer]] &g, const Ptr[RCP[Integer]] &s, - unsigned long n) nogil - RCP[const Integer] binomial(const Integer &n,unsigned long k) nogil - RCP[const Integer] factorial(unsigned long n) nogil - bool divides(const Integer &a, const Integer &b) nogil - int factor(const Ptr[RCP[Integer]] &f, const Integer &n, double B1) nogil - int factor_lehman_method(const Ptr[RCP[Integer]] &f, const Integer &n) nogil - int factor_pollard_pm1_method(const Ptr[RCP[Integer]] &f, const Integer &n, - unsigned B, unsigned retries) nogil - int factor_pollard_rho_method(const Ptr[RCP[Integer]] &f, const Integer &n, - unsigned retries) nogil - void prime_factors(vec_integer &primes, const Integer &n) nogil except + - void prime_factor_multiplicities(map_integer_uint &primes, const Integer &n) nogil except + - RCP[const Number] bernoulli(unsigned long n) nogil except + - bool primitive_root(const Ptr[RCP[Integer]] &g, const Integer &n) nogil - void primitive_root_list(vec_integer &roots, const Integer &n) nogil - RCP[const Integer] totient(RCP[const Integer] n) nogil - RCP[const Integer] carmichael(RCP[const Integer] n) nogil - bool multiplicative_order(const Ptr[RCP[Integer]] &o, RCP[const Integer] a, - RCP[const Integer] n) nogil - int legendre(const Integer &a, const Integer &n) nogil - int jacobi(const Integer &a, const Integer &n) nogil - int kronecker(const Integer &a, const Integer &n) nogil - void nthroot_mod_list(vec_integer &roots, RCP[const Integer] n, - RCP[const Integer] a, RCP[const Integer] m) nogil - bool nthroot_mod(const Ptr[RCP[Integer]] &root, RCP[const Integer] n, - RCP[const Integer] a, RCP[const Integer] m) nogil - bool powermod(const Ptr[RCP[Integer]] &powm, RCP[const Integer] a, - RCP[const Number] b, RCP[const Integer] m) nogil - void powermod_list(vec_integer &powm, RCP[const Integer] a, - RCP[const Number] b, RCP[const Integer] m) nogil - -cdef extern from "" namespace "SymEngine": - void sieve_generate_primes "SymEngine::Sieve::generate_primes"(vector[unsigned] &primes, unsigned limit) nogil - - cdef cppclass sieve_iterator "SymEngine::Sieve::iterator": - sieve_iterator() - sieve_iterator(unsigned limit) nogil - unsigned next_prime() nogil - -cdef extern from "" namespace "SymEngine": - bool has_symbol(const Basic &b, const Basic &x) nogil except + - rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) nogil except + - set_basic free_symbols(const Basic &b) nogil except + - set_basic free_symbols(const MatrixBase &b) nogil except + - unsigned count_ops(const vec_basic &a) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass Boolean(Basic): - RCP[const Boolean] logical_not() nogil except + - cdef cppclass BooleanAtom(Boolean): - bool get_val() nogil - cdef cppclass Relational(Boolean): - pass - cdef cppclass Equality(Relational): - pass - cdef cppclass Unequality(Relational): - pass - cdef cppclass LessThan(Relational): - pass - cdef cppclass StrictLessThan(Relational): - pass - cdef cppclass Piecewise(Basic): - pass - cdef cppclass Contains(Boolean): - pass - cdef cppclass And(Boolean): - pass - cdef cppclass Or(Boolean): - pass - cdef cppclass Not(Boolean): - pass - cdef cppclass Xor(Boolean): - pass - - rcp_const_basic boolTrue - rcp_const_basic boolFalse - cdef RCP[const Boolean] Eq(rcp_const_basic &lhs) nogil except + - cdef RCP[const Boolean] Eq(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + - cdef RCP[const Boolean] Ne(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + - cdef RCP[const Boolean] Ge(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + - cdef RCP[const Boolean] Gt(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + - cdef RCP[const Boolean] Le(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + - cdef RCP[const Boolean] Lt(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + - ctypedef Boolean const_Boolean "const SymEngine::Boolean" - ctypedef vector[pair[rcp_const_basic, RCP[const_Boolean]]] PiecewiseVec; - ctypedef vector[RCP[Boolean]] vec_boolean "SymEngine::vec_boolean" - ctypedef set[RCP[Boolean]] set_boolean "SymEngine::set_boolean" - cdef RCP[const Boolean] logical_and(set_boolean &s) nogil except + - cdef RCP[const Boolean] logical_nand(set_boolean &s) nogil except + - cdef RCP[const Boolean] logical_or(set_boolean &s) nogil except + - cdef RCP[const Boolean] logical_not(RCP[const Boolean] &s) nogil except + - cdef RCP[const Boolean] logical_nor(set_boolean &s) nogil except + - cdef RCP[const Boolean] logical_xor(vec_boolean &s) nogil except + - cdef RCP[const Boolean] logical_xnor(vec_boolean &s) nogil except + - cdef rcp_const_basic piecewise(PiecewiseVec vec) nogil except + - cdef RCP[const Boolean] contains(rcp_const_basic &expr, - RCP[const Set] &set) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass EvalfDomain: - pass - cdef EvalfDomain EvalfComplex "SymEngine::EvalfDomain::Complex" - cdef EvalfDomain EvalfReal "SymEngine::EvalfDomain::Real" - cdef EvalfDomain EvalfSymbolic "SymEngine::EvalfDomain::Symbolic" - rcp_const_basic evalf(const Basic &b, unsigned long bits, EvalfDomain domain) nogil except + - -cdef extern from "" namespace "SymEngine": - double eval_double(const Basic &b) nogil except + - double complex eval_complex_double(const Basic &b) nogil except + - -cdef extern from "" namespace "SymEngine": - cdef cppclass LambdaRealDoubleVisitor: - LambdaRealDoubleVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except + - void call(double *r, const double *x) nogil - cdef cppclass LambdaComplexDoubleVisitor: - LambdaComplexDoubleVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except + - void call(double complex *r, const double complex *x) nogil - -cdef extern from "" namespace "SymEngine": - cdef cppclass LLVMVisitor: - LLVMVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) nogil except + - const string& dumps() nogil - void loads(const string&) nogil - - cdef cppclass LLVMFloatVisitor(LLVMVisitor): - void call(float *r, const float *x) nogil - - cdef cppclass LLVMDoubleVisitor(LLVMVisitor): - void call(double *r, const double *x) nogil - - cdef cppclass LLVMLongDoubleVisitor(LLVMVisitor): - void call(long double *r, const long double *x) nogil - - -cdef extern from "" namespace "SymEngine": - cdef cppclass SeriesCoeffInterface: - rcp_const_basic as_basic() nogil except + - umap_int_basic as_dict() nogil except + - rcp_const_basic get_coeff(int) nogil except + - ctypedef RCP[const SeriesCoeffInterface] rcp_const_seriescoeffinterface "SymEngine::RCP" - rcp_const_seriescoeffinterface series "SymEngine::series"(rcp_const_basic &ex, RCP[const Symbol] &var, unsigned int prec) nogil except + - -cdef extern from "" namespace "SymEngine": - void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) nogil except + - -cdef extern from "" namespace "SymEngine": - void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) nogil except + - -cdef extern from "" namespace "SymEngine": - rcp_const_basic parse(const string &n) nogil except + - -cdef extern from "" namespace "SymEngine": - cdef cppclass Set(Basic): - RCP[const Set] set_intersection(RCP[const Set] &o) nogil except + - RCP[const Set] set_union(RCP[const Set] &o) nogil except + - RCP[const Set] set_complement(RCP[const Set] &o) nogil except + - RCP[const Boolean] contains(rcp_const_basic &a) nogil except + - cdef cppclass Interval(Set): - pass - cdef cppclass EmptySet(Set): - pass - cdef cppclass Reals(Set): - pass - cdef cppclass Rationals(Set): - pass - cdef cppclass Integers(Set): - pass - cdef cppclass UniversalSet(Set): - pass - cdef cppclass FiniteSet(Set): - pass - cdef cppclass Union(Set): - pass - cdef cppclass Complement(Set): - pass - cdef cppclass ConditionSet(Set): - pass - cdef cppclass ImageSet(Set): - pass - ctypedef set[RCP[Set]] set_set "SymEngine::set_set" - cdef rcp_const_basic interval(RCP[const Number] &start, RCP[const Number] &end, bool l, bool r) nogil except + - cdef RCP[const EmptySet] emptyset() nogil except + - cdef RCP[const Reals] reals() nogil except + - cdef RCP[const Rationals] rationals() nogil except + - cdef RCP[const Integers] integers() nogil except + - cdef RCP[const UniversalSet] universalset() nogil except + - cdef RCP[const Set] finiteset(set_basic &container) nogil except + - cdef RCP[const Set] set_union(set_set &a) nogil except + - cdef RCP[const Set] set_intersection(set_set &a) nogil except + - cdef RCP[const Set] set_complement_helper(RCP[const Set] &container, RCP[const Set] &universe) nogil except + - cdef RCP[const Set] set_complement(RCP[const Set] &universe, RCP[const Set] &container) nogil except + - cdef RCP[const Set] conditionset(rcp_const_basic &sym, RCP[const Boolean] &condition) nogil except + - cdef RCP[const Set] imageset(rcp_const_basic &sym, rcp_const_basic &expr, RCP[const Set] &base) nogil except + - -cdef extern from "" namespace "SymEngine": - cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym) nogil except + - cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym, RCP[const Set] &domain) nogil except + - cdef vec_basic linsolve(const vec_basic &eqs, const vec_sym &syms) nogil except + - -cdef extern from "symengine/tribool.h" namespace "SymEngine": - cdef cppclass tribool: - pass # tribool is an enum class - - cdef bool is_true(tribool) nogil - cdef bool is_false(tribool) nogil - cdef bool is_indeterminate(tribool) nogil - -cdef extern from "symengine/tribool.h" namespace "SymEngine::tribool": - cdef tribool indeterminate - cdef tribool trifalse - cdef tribool tritrue - -cdef extern from "" namespace "SymEngine": - string ccode(const Basic &x) nogil except + - string latex(const Basic &x) nogil except + - string latex(const DenseMatrix &x, unsigned max_rows, unsigned max_cols) nogil except + - string unicode(const Basic &x) nogil except + - -## Defined in 'symengine/cwrapper.cpp' -cdef struct CRCPBasic: - rcp_const_basic m diff --git a/symengine/lib/symengine_wrapper.in.pxd b/symengine/lib/symengine_wrapper.in.pxd deleted file mode 100644 index 03dbf1f0..00000000 --- a/symengine/lib/symengine_wrapper.in.pxd +++ /dev/null @@ -1,85 +0,0 @@ -#cython: language_level=3 - -cimport symengine -from symengine cimport RCP, map_basic_basic, rcp_const_basic -from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector -from libcpp.string cimport string -from libcpp cimport bool as cppbool - -cdef class Basic(object): - cdef rcp_const_basic thisptr - -cdef class MatrixBase(object): - cdef symengine.MatrixBase* thisptr - -cdef class PyFunctionClass(object): - cdef RCP[const symengine.PyFunctionClass] thisptr - -cdef class PyModule(object): - cdef RCP[const symengine.PyModule] thisptr - -cdef class _DictBasic(object): - cdef map_basic_basic c - -cdef class DictBasicIter(object): - cdef map_basic_basic.iterator begin - cdef map_basic_basic.iterator end - cdef init(self, map_basic_basic.iterator begin, map_basic_basic.iterator end) - -cdef object c2py(rcp_const_basic o) - -cdef class _Lambdify(object): - cdef size_t args_size, tot_out_size - cdef list out_shapes - cdef readonly bint real - cdef readonly size_t n_exprs - cdef public str order - cdef vector[int] accum_out_sizes - cdef object numpy_dtype - - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) - cdef _load(self, const string &s) - cpdef eval_real(self, inp, out) - cpdef eval_complex(self, inp, out) - cpdef unsafe_eval(sef, inp, out, unsigned nbroadcast=*) - -cdef class LambdaDouble(_Lambdify): - cdef unique_ptr[symengine.LambdaRealDoubleVisitor] lambda_visitor - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) - cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*) - cpdef as_scipy_low_level_callable(self) - cpdef as_ctypes(self) - cpdef unsafe_real(self, - double[::1] inp, double[::1] out, - int inp_offset=*, int out_offset=*) - -cdef class LambdaComplexDouble(_Lambdify): - cdef unique_ptr[symengine.LambdaComplexDoubleVisitor] lambda_visitor - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) - cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=*, int out_offset=*) - -IF HAVE_SYMENGINE_LLVM: - cdef class _LLVMLambdify(_Lambdify): - cdef int opt_level - - cdef class LLVMDouble(_LLVMLambdify): - cdef unique_ptr[symengine.LLVMDoubleVisitor] lambda_visitor - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) - cdef _load(self, const string &s) - cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*) - cpdef as_scipy_low_level_callable(self) - cpdef as_ctypes(self) - - cdef class LLVMFloat(_LLVMLambdify): - cdef unique_ptr[symengine.LLVMFloatVisitor] lambda_visitor - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) - cdef _load(self, const string &s) - cpdef unsafe_real(self, float[::1] inp, float[::1] out, int inp_offset=*, int out_offset=*) - - IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE: - cdef class LLVMLongDouble(_LLVMLambdify): - cdef unique_ptr[symengine.LLVMLongDoubleVisitor] lambda_visitor - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) - cdef _load(self, const string &s) - cpdef unsafe_real(self, long double[::1] inp, long double[::1] out, int inp_offset=*, int out_offset=*) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx deleted file mode 100644 index 6fe0ffa5..00000000 --- a/symengine/lib/symengine_wrapper.in.pyx +++ /dev/null @@ -1,5705 +0,0 @@ -from cython.operator cimport dereference as deref, preincrement as inc -cimport symengine -from symengine cimport (RCP, pair, map_basic_basic, umap_int_basic, - umap_int_basic_iterator, umap_basic_num, umap_basic_num_iterator, - rcp_const_basic, std_pair_short_rcp_const_basic, - rcp_const_seriescoeffinterface, CRCPBasic, tribool, is_indeterminate, is_true, is_false) -from libcpp cimport bool as cppbool -from libcpp.utility cimport move -from libcpp.string cimport string -from libcpp.vector cimport vector -from cpython cimport PyObject, Py_XINCREF, Py_XDECREF, \ - PyObject_CallMethodObjArgs -from libc.string cimport memcpy -import cython -import itertools -import numbers -from operator import mul -from functools import reduce -import collections -import warnings -from symengine.utilities import is_sequence -import os -import sys -from cpython.pycapsule cimport PyCapsule_GetPointer -from collections.abc import MutableMapping - -try: - import numpy as np - # Lambdify requires NumPy (since b713a61, see gh-112) - have_numpy = True -except ImportError: - have_numpy = False - - -class SympifyError(Exception): - pass - -cpdef object capsule_to_basic(object capsule): - cdef CRCPBasic *p = PyCapsule_GetPointer(capsule, NULL) - return c2py(p.m) - -cpdef void assign_to_capsule(object capsule, object value): - cdef CRCPBasic *p_cap = PyCapsule_GetPointer(capsule, NULL) - cdef Basic v = sympify(value) - p_cap.m = v.thisptr - -cdef object c2py(rcp_const_basic o): - cdef Basic r - cdef PyObject *obj - if (symengine.is_a[symengine.Add](deref(o))): - r = Expr.__new__(Add) - elif (symengine.is_a[symengine.Mul](deref(o))): - r = Expr.__new__(Mul) - elif (symengine.is_a[symengine.Pow](deref(o))): - r = Expr.__new__(Pow) - elif (symengine.is_a[symengine.Integer](deref(o))): - if (deref(symengine.rcp_static_cast_Integer(o)).is_zero()): - return S.Zero - elif (deref(symengine.rcp_static_cast_Integer(o)).is_one()): - return S.One - elif (deref(symengine.rcp_static_cast_Integer(o)).is_minus_one()): - return S.NegativeOne - r = Number.__new__(Integer) - elif (symengine.is_a[symengine.Rational](deref(o))): - r = S.Half - if (symengine.eq(deref(o), deref(r.thisptr))): - return S.Half - r = Number.__new__(Rational) - elif (symengine.is_a[symengine.Complex](deref(o))): - r = S.ImaginaryUnit - if (symengine.eq(deref(o), deref(r.thisptr))): - return S.ImaginaryUnit - r = Complex.__new__(Complex) - elif (symengine.is_a[symengine.Dummy](deref(o))): - r = Dummy.__new__(Dummy) - elif (symengine.is_a[symengine.Symbol](deref(o))): - if (symengine.is_a_sub[symengine.PySymbol](deref(o))): - obj = deref(symengine.rcp_static_cast_PySymbol(o)).get_py_object() - result = (obj) - Py_XDECREF(obj); - return result - r = Symbol.__new__(Symbol) - elif (symengine.is_a[symengine.Constant](deref(o))): - r = S.Pi - if (symengine.eq(deref(o), deref(r.thisptr))): - return S.Pi - r = S.Exp1 - if (symengine.eq(deref(o), deref(r.thisptr))): - return S.Exp1 - r = S.GoldenRatio - if (symengine.eq(deref(o), deref(r.thisptr))): - return S.GoldenRatio - r = S.Catalan - if (symengine.eq(deref(o), deref(r.thisptr))): - return S.Catalan - r = S.EulerGamma - if (symengine.eq(deref(o), deref(r.thisptr))): - return S.EulerGamma - r = Constant.__new__(Constant) - elif (symengine.is_a[symengine.Infty](deref(o))): - if (deref(symengine.rcp_static_cast_Infty(o)).is_positive()): - return S.Infinity - elif (deref(symengine.rcp_static_cast_Infty(o)).is_negative()): - return S.NegativeInfinity - return S.ComplexInfinity - elif (symengine.is_a[symengine.NaN](deref(o))): - return S.NaN - elif (symengine.is_a[symengine.PyFunction](deref(o))): - r = PyFunction.__new__(PyFunction) - elif (symengine.is_a[symengine.FunctionSymbol](deref(o))): - r = FunctionSymbol.__new__(FunctionSymbol) - elif (symengine.is_a[symengine.Abs](deref(o))): - r = Function.__new__(Abs) - elif (symengine.is_a[symengine.Max](deref(o))): - r = Function.__new__(Max) - elif (symengine.is_a[symengine.Min](deref(o))): - r = Function.__new__(Min) - elif (symengine.is_a[symengine.BooleanAtom](deref(o))): - if (deref(symengine.rcp_static_cast_BooleanAtom(o)).get_val()): - return S.true - return S.false - elif (symengine.is_a[symengine.Equality](deref(o))): - r = Relational.__new__(Equality) - elif (symengine.is_a[symengine.Unequality](deref(o))): - r = Relational.__new__(Unequality) - elif (symengine.is_a[symengine.LessThan](deref(o))): - r = Relational.__new__(LessThan) - elif (symengine.is_a[symengine.StrictLessThan](deref(o))): - r = Relational.__new__(StrictLessThan) - elif (symengine.is_a[symengine.Gamma](deref(o))): - r = Function.__new__(Gamma) - elif (symengine.is_a[symengine.Derivative](deref(o))): - r = Expr.__new__(Derivative) - elif (symengine.is_a[symengine.Subs](deref(o))): - r = Expr.__new__(Subs) - elif (symengine.is_a[symengine.RealDouble](deref(o))): - r = Number.__new__(RealDouble) - elif (symengine.is_a[symengine.ComplexDouble](deref(o))): - r = ComplexDouble.__new__(ComplexDouble) - elif (symengine.is_a[symengine.RealMPFR](deref(o))): - r = Number.__new__(RealMPFR) - elif (symengine.is_a[symengine.ComplexMPC](deref(o))): - r = ComplexMPC.__new__(ComplexMPC) - elif (symengine.is_a[symengine.Log](deref(o))): - r = Function.__new__(Log) - elif (symengine.is_a[symengine.Sin](deref(o))): - r = Function.__new__(Sin) - elif (symengine.is_a[symengine.Cos](deref(o))): - r = Function.__new__(Cos) - elif (symengine.is_a[symengine.Tan](deref(o))): - r = Function.__new__(Tan) - elif (symengine.is_a[symengine.Cot](deref(o))): - r = Function.__new__(Cot) - elif (symengine.is_a[symengine.Csc](deref(o))): - r = Function.__new__(Csc) - elif (symengine.is_a[symengine.Sec](deref(o))): - r = Function.__new__(Sec) - elif (symengine.is_a[symengine.ASin](deref(o))): - r = Function.__new__(ASin) - elif (symengine.is_a[symengine.ACos](deref(o))): - r = Function.__new__(ACos) - elif (symengine.is_a[symengine.ATan](deref(o))): - r = Function.__new__(ATan) - elif (symengine.is_a[symengine.ACot](deref(o))): - r = Function.__new__(ACot) - elif (symengine.is_a[symengine.ACsc](deref(o))): - r = Function.__new__(ACsc) - elif (symengine.is_a[symengine.ASec](deref(o))): - r = Function.__new__(ASec) - elif (symengine.is_a[symengine.Sinh](deref(o))): - r = Function.__new__(Sinh) - elif (symengine.is_a[symengine.Cosh](deref(o))): - r = Function.__new__(Cosh) - elif (symengine.is_a[symengine.Tanh](deref(o))): - r = Function.__new__(Tanh) - elif (symengine.is_a[symengine.Coth](deref(o))): - r = Function.__new__(Coth) - elif (symengine.is_a[symengine.Csch](deref(o))): - r = Function.__new__(Csch) - elif (symengine.is_a[symengine.Sech](deref(o))): - r = Function.__new__(Sech) - elif (symengine.is_a[symengine.ASinh](deref(o))): - r = Function.__new__(ASinh) - elif (symengine.is_a[symengine.ACosh](deref(o))): - r = Function.__new__(ACosh) - elif (symengine.is_a[symengine.ATanh](deref(o))): - r = Function.__new__(ATanh) - elif (symengine.is_a[symengine.ACoth](deref(o))): - r = Function.__new__(ACoth) - elif (symengine.is_a[symengine.ACsch](deref(o))): - r = Function.__new__(ACsch) - elif (symengine.is_a[symengine.ASech](deref(o))): - r = Function.__new__(ASech) - elif (symengine.is_a[symengine.ATan2](deref(o))): - r = Function.__new__(ATan2) - elif (symengine.is_a[symengine.LambertW](deref(o))): - r = Function.__new__(LambertW) - elif (symengine.is_a[symengine.Zeta](deref(o))): - r = Function.__new__(zeta) - elif (symengine.is_a[symengine.Dirichlet_eta](deref(o))): - r = Function.__new__(dirichlet_eta) - elif (symengine.is_a[symengine.KroneckerDelta](deref(o))): - r = Function.__new__(KroneckerDelta) - elif (symengine.is_a[symengine.LeviCivita](deref(o))): - r = Function.__new__(LeviCivita) - elif (symengine.is_a[symengine.Erf](deref(o))): - r = Function.__new__(erf) - elif (symengine.is_a[symengine.Erfc](deref(o))): - r = Function.__new__(erfc) - elif (symengine.is_a[symengine.LowerGamma](deref(o))): - r = Function.__new__(lowergamma) - elif (symengine.is_a[symengine.UpperGamma](deref(o))): - r = Function.__new__(uppergamma) - elif (symengine.is_a[symengine.LogGamma](deref(o))): - r = Function.__new__(loggamma) - elif (symengine.is_a[symengine.Beta](deref(o))): - r = Function.__new__(beta) - elif (symengine.is_a[symengine.PolyGamma](deref(o))): - r = Function.__new__(polygamma) - elif (symengine.is_a[symengine.Sign](deref(o))): - r = Function.__new__(sign) - elif (symengine.is_a[symengine.Floor](deref(o))): - r = Function.__new__(floor) - elif (symengine.is_a[symengine.Ceiling](deref(o))): - r = Function.__new__(ceiling) - elif (symengine.is_a[symengine.Conjugate](deref(o))): - r = Function.__new__(conjugate) - elif (symengine.is_a[symengine.PyNumber](deref(o))): - r = PyNumber.__new__(PyNumber) - elif (symengine.is_a[symengine.Piecewise](deref(o))): - r = Function.__new__(Piecewise) - elif (symengine.is_a[symengine.Contains](deref(o))): - r = Boolean.__new__(Contains) - elif (symengine.is_a[symengine.Interval](deref(o))): - r = Set.__new__(Interval) - elif (symengine.is_a[symengine.EmptySet](deref(o))): - r = Set.__new__(EmptySet) - elif (symengine.is_a[symengine.Reals](deref(o))): - r = Set.__new__(Reals) - elif (symengine.is_a[symengine.Integers](deref(o))): - r = Set.__new__(Integers) - elif (symengine.is_a[symengine.Rationals](deref(o))): - r = Set.__new__(Rationals) - elif (symengine.is_a[symengine.UniversalSet](deref(o))): - r = Set.__new__(UniversalSet) - elif (symengine.is_a[symengine.FiniteSet](deref(o))): - r = Set.__new__(FiniteSet) - elif (symengine.is_a[symengine.Union](deref(o))): - r = Set.__new__(Union) - elif (symengine.is_a[symengine.Complement](deref(o))): - r = Set.__new__(Complement) - elif (symengine.is_a[symengine.ConditionSet](deref(o))): - r = Set.__new__(ConditionSet) - elif (symengine.is_a[symengine.ImageSet](deref(o))): - r = Set.__new__(ImageSet) - elif (symengine.is_a[symengine.And](deref(o))): - r = Boolean.__new__(And) - elif (symengine.is_a[symengine.Not](deref(o))): - r = Boolean.__new__(Not) - elif (symengine.is_a[symengine.Or](deref(o))): - r = Boolean.__new__(Or) - elif (symengine.is_a[symengine.Xor](deref(o))): - r = Boolean.__new__(Xor) - elif (symengine.is_a[symengine.UnevaluatedExpr](deref(o))): - r = Function.__new__(UnevaluatedExpr) - else: - raise Exception("Unsupported SymEngine class.") - r.thisptr = o - return r - -def sympy2symengine(a, raise_error=False): - """ - Converts 'a' from SymPy to SymEngine. - - If the expression cannot be converted, it either returns None (if - raise_error==False) or raises a SympifyError exception (if - raise_error==True). - """ - import sympy - from sympy.core.function import AppliedUndef as sympy_AppliedUndef - if isinstance(a, sympy.Symbol): - return Symbol(a.name) - elif isinstance(a, sympy.Dummy): - return Dummy(a.name) - elif isinstance(a, sympy.Mul): - return mul(*[sympy2symengine(x, raise_error) for x in a.args]) - elif isinstance(a, sympy.Add): - return add(*[sympy2symengine(x, raise_error) for x in a.args]) - elif isinstance(a, (sympy.Pow, sympy.exp)): - x, y = a.as_base_exp() - return sympy2symengine(x, raise_error) ** sympy2symengine(y, raise_error) - elif isinstance(a, sympy.Integer): - return Integer(a.p) - elif isinstance(a, sympy.Rational): - return Integer(a.p) / Integer(a.q) - elif isinstance(a, sympy.Float): - IF HAVE_SYMENGINE_MPFR: - if a._prec > 53: - return RealMPFR(str(a), a._prec) - else: - return RealDouble(float(a)) - ELSE: - return RealDouble(float(a)) - elif a is sympy.I: - return I - elif a is sympy.E: - return E - elif a is sympy.pi: - return pi - elif a is sympy.GoldenRatio: - return golden_ratio - elif a is sympy.Catalan: - return catalan - elif a is sympy.EulerGamma: - return eulergamma - elif a is sympy.S.NegativeInfinity: - return minus_oo - elif a is sympy.S.Infinity: - return oo - elif a is sympy.S.ComplexInfinity: - return zoo - elif a is sympy.nan: - return nan - elif a is sympy.S.true: - return true - elif a is sympy.S.false: - return false - elif isinstance(a, sympy.functions.elementary.trigonometric.TrigonometricFunction): - if isinstance(a, sympy.sin): - return sin(a.args[0]) - elif isinstance(a, sympy.cos): - return cos(a.args[0]) - elif isinstance(a, sympy.tan): - return tan(a.args[0]) - elif isinstance(a, sympy.cot): - return cot(a.args[0]) - elif isinstance(a, sympy.csc): - return csc(a.args[0]) - elif isinstance(a, sympy.sec): - return sec(a.args[0]) - elif isinstance(a, sympy.functions.elementary.trigonometric.InverseTrigonometricFunction): - if isinstance(a, sympy.asin): - return asin(a.args[0]) - elif isinstance(a, sympy.acos): - return acos(a.args[0]) - elif isinstance(a, sympy.atan): - return atan(a.args[0]) - elif isinstance(a, sympy.acot): - return acot(a.args[0]) - elif isinstance(a, sympy.acsc): - return acsc(a.args[0]) - elif isinstance(a, sympy.asec): - return asec(a.args[0]) - elif isinstance(a, sympy.atan2): - return atan2(*a.args) - elif isinstance(a, sympy.functions.elementary.hyperbolic.HyperbolicFunction): - if isinstance(a, sympy.sinh): - return sinh(a.args[0]) - elif isinstance(a, sympy.cosh): - return cosh(a.args[0]) - elif isinstance(a, sympy.tanh): - return tanh(a.args[0]) - elif isinstance(a, sympy.coth): - return coth(a.args[0]) - elif isinstance(a, sympy.csch): - return csch(a.args[0]) - elif isinstance(a, sympy.sech): - return sech(a.args[0]) - elif isinstance(a, sympy.asinh): - return asinh(a.args[0]) - elif isinstance(a, sympy.acosh): - return acosh(a.args[0]) - elif isinstance(a, sympy.atanh): - return atanh(a.args[0]) - elif isinstance(a, sympy.acoth): - return acoth(a.args[0]) - elif isinstance(a, sympy.log): - return log(a.args[0]) - elif isinstance(a, sympy.Abs): - return abs(sympy2symengine(a.args[0], raise_error)) - elif isinstance(a, sympy.Max): - return _max(*a.args) - elif isinstance(a, sympy.Min): - return _min(*a.args) - elif isinstance(a, sympy.Equality): - return eq(*a.args) - elif isinstance(a, sympy.Unequality): - return ne(*a.args) - elif isinstance(a, sympy.GreaterThan): - return ge(*a.args) - elif isinstance(a, sympy.StrictGreaterThan): - return gt(*a.args) - elif isinstance(a, sympy.LessThan): - return le(*a.args) - elif isinstance(a, sympy.StrictLessThan): - return lt(*a.args) - elif isinstance(a, sympy.LambertW): - return LambertW(a.args[0]) - elif isinstance(a, sympy.zeta): - return zeta(*a.args) - elif isinstance(a, sympy.dirichlet_eta): - return dirichlet_eta(a.args[0]) - elif isinstance(a, sympy.KroneckerDelta): - return KroneckerDelta(*a.args) - elif isinstance(a, sympy.LeviCivita): - return LeviCivita(*a.args) - elif isinstance(a, sympy.erf): - return erf(a.args[0]) - elif isinstance(a, sympy.erfc): - return erfc(a.args[0]) - elif isinstance(a, sympy.lowergamma): - return lowergamma(*a.args) - elif isinstance(a, sympy.uppergamma): - return uppergamma(*a.args) - elif isinstance(a, sympy.loggamma): - return loggamma(a.args[0]) - elif isinstance(a, sympy.beta): - return beta(*a.args) - elif isinstance(a, sympy.polygamma): - return polygamma(*a.args) - elif isinstance(a, sympy.sign): - return sign(a.args[0]) - elif isinstance(a, sympy.floor): - return floor(a.args[0]) - elif isinstance(a, sympy.ceiling): - return ceiling(a.args[0]) - elif isinstance(a, sympy.conjugate): - return conjugate(a.args[0]) - elif isinstance(a, sympy.And): - return logical_and(*a.args) - elif isinstance(a, sympy.Or): - return logical_or(*a.args) - elif isinstance(a, sympy.Not): - return logical_not(a.args[0]) - elif isinstance(a, sympy.Nor): - return Nor(*a.args) - elif isinstance(a, sympy.Nand): - return Nand(*a.args) - elif isinstance(a, sympy.Xor): - return logical_xor(*a.args) - elif isinstance(a, sympy.gamma): - return gamma(a.args[0]) - elif isinstance(a, sympy.Derivative): - return Derivative(a.expr, *a.variables) - elif isinstance(a, sympy.Subs): - return Subs(a.expr, a.variables, a.point) - elif isinstance(a, sympy_AppliedUndef): - name = str(a.func) - return function_symbol(name, *(a.args)) - elif isinstance(a, (sympy.Piecewise)): - return piecewise(*(a.args)) - elif a is sympy.S.Reals: - return S.Reals - elif a is sympy.S.Integers: - return S.Integers - elif a is sympy.S.Rationals: - return S.Rationals - elif isinstance(a, sympy.Interval): - return interval(*(a.args)) - elif a is sympy.S.EmptySet: - return S.EmptySet - elif a is sympy.S.UniversalSet: - return S.UniversalSet - elif isinstance(a, sympy.FiniteSet): - return finiteset(*(a.args)) - elif isinstance(a, sympy.Contains): - return contains(*(a.args)) - elif isinstance(a, sympy.Union): - return set_union(*(a.args)) - elif isinstance(a, sympy.Intersection): - return set_intersection(*(a.args)) - elif isinstance(a, sympy.Complement): - return set_complement(*(a.args)) - elif isinstance(a, sympy.ImageSet): - return imageset(*(a.args)) - elif isinstance(a, sympy.Function): - return PyFunction(a, a.args, a.func, sympy_module) - elif isinstance(a, sympy.UnevaluatedExpr): - return UnevaluatedExpr(a.args[0]) - elif isinstance(a, sympy.MatrixBase): - row, col = a.shape - v = [] - for r in a.tolist(): - for e in r: - v.append(e) - if isinstance(a, sympy.MutableDenseMatrix): - return MutableDenseMatrix(row, col, v) - elif isinstance(a, sympy.ImmutableDenseMatrix): - return ImmutableDenseMatrix(row, col, v) - else: - raise NotImplementedError - elif isinstance(a, sympy.polys.domains.modularinteger.ModularInteger): - return PyNumber(a, sympy_module) - elif sympy.__version__ > '1.0': - if isinstance(a, sympy.acsch): - return acsch(a.args[0]) - elif isinstance(a, sympy.asech): - return asech(a.args[0]) - elif isinstance(a, sympy.ConditionSet): - return conditionset(*(a.args)) - - if raise_error: - raise SympifyError(("sympy2symengine: Cannot convert '%r' (of type %s)" - " to a symengine type.") % (a, type(a))) - - -def sympify(a): - """ - Converts an expression 'a' into a SymEngine type. - - Arguments - ========= - - a ............. An expression to convert. - - Examples - ======== - - >>> from symengine import sympify - >>> sympify(1) - 1 - >>> sympify("a+b") - a + b - """ - if isinstance(a, str): - return c2py(symengine.parse(a.encode("utf-8"))) - elif isinstance(a, tuple): - v = [] - for e in a: - v.append(sympify(e)) - return tuple(v) - elif isinstance(a, list): - v = [] - for e in a: - v.append(sympify(e)) - return v - return _sympify(a, True) - - -def _sympify(a, raise_error=True): - """ - Converts an expression 'a' into a SymEngine type. - - Arguments - ========= - - a ............. An expression to convert. - raise_error ... Will raise an error on a failure (default True), otherwise - it returns None if 'a' cannot be converted. - - Examples - ======== - - >>> from symengine.li.symengine_wrapper import _sympify - >>> _sympify(1) - 1 - >>> _sympify("abc", False) - >>> - - """ - if isinstance(a, (Basic, MatrixBase)): - return a - elif isinstance(a, bool): - return (true if a else false) - elif isinstance(a, numbers.Integral): - return Integer(a) - elif isinstance(a, float): - return RealDouble(a) - elif have_numpy and isinstance(a, (np.float16, np.float32)): - return RealDouble(a) - elif isinstance(a, complex): - return ComplexDouble(a) - elif hasattr(a, '_symengine_'): - return _sympify(a._symengine_(), raise_error) - elif hasattr(a, '_sympy_'): - return _sympify(a._sympy_(), raise_error) - elif hasattr(a, 'pyobject'): - return _sympify(a.pyobject(), raise_error) - - try: - import sympy - return sympy2symengine(a, raise_error) - except ImportError: - pass - - if raise_error: - raise SympifyError( - "sympify: Cannot convert '%r' (of type %s) to a symengine type." % ( - a, type(a))) - -funcs = {} - -def get_function_class(function, module): - if not function in funcs: - funcs[function] = PyFunctionClass(function, module) - return funcs[function] - -class Singleton(object): - - __call__ = staticmethod(sympify) - - @property - def Zero(self): - return zero - - @property - def One(self): - return one - - @property - def NegativeOne(self): - return minus_one - - @property - def Half(self): - return half - - @property - def Pi(self): - return pi - - @property - def NaN(self): - return nan - - @property - def Infinity(self): - return oo - - @property - def NegativeInfinity(self): - return minus_oo - - @property - def ComplexInfinity(self): - return zoo - - @property - def Exp1(self): - return E - - @property - def GoldenRatio(self): - return golden_ratio - - @property - def Catalan(self): - return catalan - - @property - def EulerGamma(self): - return eulergamma - - @property - def ImaginaryUnit(self): - return I - - @property - def true(self): - return true - - @property - def false(self): - return false - - @property - def EmptySet(self): - return empty_set_singleton - - @property - def UniversalSet(self): - return universal_set_singleton - - @property - def Integers(self): - return integers_singleton - - @property - def Rationals(self): - return rationals_singleton - - @property - def Reals(self): - return reals_singleton - -S = Singleton() - - -cdef class DictBasicIter(object): - - cdef init(self, map_basic_basic.iterator begin, map_basic_basic.iterator end): - self.begin = begin - self.end = end - - def __iter__(self): - return self - - def __next__(self): - if self.begin != self.end: - obj = c2py(deref(self.begin).first) - else: - raise StopIteration - inc(self.begin) - return obj - - -cdef class _DictBasic(object): - - def __init__(self, tocopy = None): - if tocopy != None: - self.add_dict(tocopy) - - def as_dict(self): - ret = {} - it = self.c.begin() - while it != self.c.end(): - ret[c2py(deref(it).first)] = c2py(deref(it).second) - inc(it) - return ret - - def add_dict(self, d): - cdef _DictBasic D - if isinstance(d, DictBasic): - D = d - self.c.insert(D.c.begin(), D.c.end()) - else: - for key, value in d.iteritems(): - self.add(key, value) - - def add(self, key, value): - cdef Basic K = sympify(key) - cdef Basic V = sympify(value) - cdef symengine.std_pair_rcp_const_basic_rcp_const_basic pair - pair.first = K.thisptr - pair.second = V.thisptr - return self.c.insert(pair).second - - def copy(self): - return DictBasic(self) - - __copy__ = copy - - def __len__(self): - return self.c.size() - - def __getitem__(self, key): - cdef Basic K = sympify(key) - it = self.c.find(K.thisptr) - if it == self.c.end(): - raise KeyError(key) - else: - return c2py(deref(it).second) - - def __setitem__(self, key, value): - cdef Basic K = sympify(key) - cdef Basic V = sympify(value) - self.c[K.thisptr] = V.thisptr - - def clear(self): - self.clear() - - def __delitem__(self, key): - cdef Basic K = sympify(key) - self.c.erase(K.thisptr) - - def __contains__(self, key): - cdef Basic K = sympify(key) - it = self.c.find(K.thisptr) - return it != self.c.end() - - def __iter__(self): - cdef DictBasicIter d = DictBasicIter() - d.init(self.c.begin(), self.c.end()) - return d - - -class DictBasic(_DictBasic, MutableMapping): - - def __str__(self): - return "{" + ", ".join(["%s: %s" % (str(key), str(value)) for key, value in self.items()]) + "}" - - def __repr__(self): - return self.__str__() - -def get_dict(*args): - """ - Returns a DictBasic instance from args. Inputs can be, - 1. a DictBasic - 2. a Python dictionary - 3. two args old, new - """ - cdef _DictBasic D = DictBasic() - if len(args) == 2: - if is_sequence(args[0]): - for k, v in zip(args[0], args[1]): - D.add(k, v) - else: - D.add(args[0], args[1]) - return D - elif len(args) == 1: - arg = args[0] - else: - raise TypeError("subs/msubs takes one or two arguments (%d given)" % \ - len(args)) - if isinstance(arg, DictBasic): - return arg - for k, v in arg.items(): - D.add(k, v) - return D - - -cdef tuple vec_basic_to_tuple(symengine.vec_basic& vec): - return tuple(vec_basic_to_list(vec)) - - -cdef list vec_basic_to_list(symengine.vec_basic& vec): - result = [] - for i in range(vec.size()): - result.append(c2py((vec[i]))) - return result - - -cdef list vec_pair_to_list(symengine.vec_pair& vec): - result = [] - cdef rcp_const_basic a, b - for i in range(vec.size()): - a = vec[i].first - b = vec[i].second - result.append((c2py(a), c2py(b))) - return result - - -def load_basic(bytes s): - return c2py(symengine.wrapper_loads(s)) - - -repr_latex=[False] - -cdef class Basic(object): - - def __str__(self): - return deref(self.thisptr).__str__().decode("utf-8") - - def __repr__(self): - return self.__str__() - - def __reduce__(self): - cdef bytes s = symengine.wrapper_dumps(deref(self.thisptr)) - return (load_basic, (s,)) - - def _repr_latex_(self): - if repr_latex[0]: - return "${}$".format(latex(self)) - else: - return None - - def __hash__(self): - return deref(self.thisptr).hash() - - def __dealloc__(self): - self.thisptr.reset() - - def _unsafe_reset(self): - self.thisptr.reset() - - def __add__(a, b): - cdef Basic A = _sympify(a, False) - B_ = _sympify(b, False) - if A is None or B_ is None or isinstance(B_, MatrixBase): return NotImplemented - cdef Basic B = B_ - return c2py(symengine.add(A.thisptr, B.thisptr)) - - def __radd__(Basic self, b): - B_ = _sympify(b, False) - if B_ is None or isinstance(B_, MatrixBase): return NotImplemented - cdef Basic B = B_ - return c2py(symengine.add(B.thisptr, self.thisptr)) - - def __sub__(a, b): - cdef Basic A = _sympify(a, False) - B_ = _sympify(b, False) - if A is None or B_ is None or isinstance(B_, MatrixBase): return NotImplemented - cdef Basic B = B_ - return c2py(symengine.sub(A.thisptr, B.thisptr)) - - def __rsub__(Basic self, b): - B_ = _sympify(b, False) - if B_ is None or isinstance(B_, MatrixBase): return NotImplemented - cdef Basic B = B_ - return c2py(symengine.sub(B.thisptr, self.thisptr)) - - def __mul__(a, b): - cdef Basic A = _sympify(a, False) - B_ = _sympify(b, False) - if A is None or B_ is None or isinstance(B_, MatrixBase): return NotImplemented - cdef Basic B = B_ - return c2py(symengine.mul(A.thisptr, B.thisptr)) - - def __rmul__(Basic self, b): - B_ = _sympify(b, False) - if B_ is None or isinstance(B_, MatrixBase): return NotImplemented - cdef Basic B = B_ - return c2py(symengine.mul(B.thisptr, self.thisptr)) - - def __truediv__(a, b): - cdef Basic A = _sympify(a, False) - B_ = _sympify(b, False) - if A is None or B_ is None or isinstance(B_, MatrixBase): return NotImplemented - cdef Basic B = B_ - return c2py(symengine.div(A.thisptr, B.thisptr)) - - def __rtruediv__(Basic self, b): - B_ = _sympify(b, False) - if B_ is None or isinstance(B_, MatrixBase): return NotImplemented - cdef Basic B = B_ - return c2py(symengine.div(B.thisptr, self.thisptr)) - - def __floordiv__(x, y): - return floor(x/y) - - def __rfloordiv__(y, x): - return floor(x/y) - - def __mod__(x, y): - return x - y * floor(x/y) - - def __rmod__(y, x): - return x - y * floor(x/y) - - def __divmod__(x, y): - f = floor(x/y) - return f, x - y * f - - def __rdivmod__(y, x): - f = floor(x/y) - return f, x - y * f - - def __pow__(a, b, c): - if c is not None: - return powermod(a, b, c) - cdef Basic A = _sympify(a, False) - cdef Basic B = _sympify(b, False) - if A is None or B is None: return NotImplemented - return c2py(symengine.pow(A.thisptr, B.thisptr)) - - def __rpow__(Basic self, b): - cdef Basic B = _sympify(b, False) - if B is None: return NotImplemented - return c2py(symengine.pow(B.thisptr, self.thisptr)) - - def __neg__(Basic self not None): - return c2py(symengine.neg(self.thisptr)) - - def __pos__(self): - return self - - def __abs__(Basic self not None): - return c2py(symengine.abs(self.thisptr)) - - def __richcmp__(a, b, int op): - A = _sympify(a, False) - B = _sympify(b, False) - if not (isinstance(A, Basic) and isinstance(B, Basic)): - if (op == 2): - return False - elif (op == 3): - return True - else: - return NotImplemented - return Basic._richcmp_(A, B, op) - - def _richcmp_(Basic A, Basic B, int op): - if (op == 2): - return symengine.eq(deref(A.thisptr), deref(B.thisptr)) - elif (op == 3): - return symengine.neq(deref(A.thisptr), deref(B.thisptr)) - if (op == 0): - return c2py((symengine.Lt(A.thisptr, B.thisptr))) - elif (op == 1): - return c2py((symengine.Le(A.thisptr, B.thisptr))) - elif (op == 4): - return c2py((symengine.Gt(A.thisptr, B.thisptr))) - elif (op == 5): - return c2py((symengine.Ge(A.thisptr, B.thisptr))) - - def expand(Basic self not None, cppbool deep=True): - return c2py(symengine.expand(self.thisptr, deep)) - - def _diff(Basic self not None, Basic x): - return c2py(symengine.diff(self.thisptr, x.thisptr)) - - def diff(self, *args): - if len(args) == 0: - f = self.free_symbols - if (len(f) != 1): - raise RuntimeError("Variable w.r.t should be given") - return self._diff(f.pop()) - return _diff(self, *args) - - def subs_dict(Basic self not None, *args): - warnings.warn("subs_dict() is deprecated. Use subs() instead", DeprecationWarning) - return self.subs(*args) - - def subs_oldnew(Basic self not None, old, new): - warnings.warn("subs_oldnew() is deprecated. Use subs() instead", DeprecationWarning) - return self.subs({old: new}) - - def subs(Basic self not None, *args): - cdef _DictBasic D = get_dict(*args) - return c2py(symengine.ssubs(self.thisptr, D.c)) - - def xreplace(Basic self not None, *args): - cdef _DictBasic D = get_dict(*args) - return c2py(symengine.xreplace(self.thisptr, D.c)) - - replace = xreplace - - def msubs(Basic self not None, *args): - cdef _DictBasic D = get_dict(*args) - return c2py(symengine.msubs(self.thisptr, D.c)) - - def as_numer_denom(Basic self not None): - cdef rcp_const_basic _num, _den - symengine.as_numer_denom(self.thisptr, symengine.outArg(_num), symengine.outArg(_den)) - return c2py(_num), c2py(_den) - - def as_real_imag(Basic self not None): - cdef rcp_const_basic _real, _imag - symengine.as_real_imag(self.thisptr, symengine.outArg(_real), symengine.outArg(_imag)) - return c2py(_real), c2py(_imag) - - def n(self, unsigned long prec = 53, real=None): - return evalf(self, prec, real) - - evalf = n - - @property - def args(self): - cdef symengine.vec_basic args = deref(self.thisptr).get_args() - return vec_basic_to_tuple(args) - - @property - def free_symbols(self): - cdef symengine.set_basic _set = symengine.free_symbols(deref(self.thisptr)) - return {c2py((elem)) for elem in _set} - - @property - def is_Atom(self): - return False - - @property - def is_Symbol(self): - return False - - @property - def is_symbol(self): - return False - - @property - def is_Dummy(self): - return False - - @property - def is_Function(self): - return False - - @property - def is_Add(self): - return False - - @property - def is_Mul(self): - return False - - @property - def is_Pow(self): - return False - - @property - def is_Number(self): - return False - - @property - def is_number(self): - return None - - @property - def is_Float(self): - return False - - @property - def is_Rational(self): - return False - - @property - def is_Integer(self): - return False - - @property - def is_integer(self): - return False - - @property - def is_finite(self): - return None - - @property - def is_Derivative(self): - return False - - @property - def is_AlgebraicNumber(self): - return False - - @property - def is_Relational(self): - return False - - @property - def is_Equality(self): - return False - - @property - def is_Boolean(self): - return False - - @property - def is_Not(self): - return False - - @property - def is_Matrix(self): - return False - - @property - def is_zero(self): - return is_zero(self) - - @property - def is_positive(self): - return is_positive(self) - - @property - def is_negative(self): - return is_negative(self) - - @property - def is_nonpositive(self): - return is_nonpositive(self) - - @property - def is_nonnegative(self): - return is_nonnegative(self) - - @property - def is_real(self): - return is_real(self) - - def copy(self): - return self - - def _symbolic_(self, ring): - return ring(self._sage_()) - - def atoms(self, *types): - if types: - s = set() - if (isinstance(self, types)): - s.add(self) - for arg in self.args: - s.update(arg.atoms(*types)) - return s - else: - return self.free_symbols - - def simplify(self, *args, **kwargs): - return sympify(self._sympy_().simplify(*args, **kwargs)) - - def as_coefficients_dict(self): - d = collections.defaultdict(int) - d[self] = 1 - return d - - def coeff(self, x, n=1): - cdef Basic _x = sympify(x) - require(_x, Symbol) - cdef Basic _n = sympify(n) - return c2py(symengine.coeff(deref(self.thisptr), deref(_x.thisptr), deref(_n.thisptr))) - - def has(self, *symbols): - return any([has_symbol(self, symbol) for symbol in symbols]) - - def args_as_sage(Basic self): - cdef symengine.vec_basic Y = deref(self.thisptr).get_args() - s = [] - for i in range(Y.size()): - s.append(c2py((Y[i]))._sage_()) - return s - - def args_as_sympy(Basic self): - cdef symengine.vec_basic Y = deref(self.thisptr).get_args() - s = [] - for i in range(Y.size()): - s.append(c2py((Y[i]))._sympy_()) - return s - - def __float__(self): - f = self.n(real=True) - if not isinstance(f, RealDouble): - raise TypeError("Can't convert expression to float") - return float(f) - - def __int__(self): - return int(float(self)) - - def __complex__(self): - f = self.n(real=False) - if not isinstance(f, (ComplexDouble, RealDouble)): - raise TypeError("Can't convert expression to float") - return complex(f) - - def as_powers_dict(self): - d = collections.defaultdict(int) - d[self] = 1 - return d - - -def series(ex, x=None, x0=0, n=6, as_deg_coef_pair=False): - # TODO: check for x0 an infinity, see sympy/core/expr.py - # TODO: nonzero x0 - # underscored local vars are of symengine.py type - cdef Basic _ex = sympify(ex) - syms = _ex.free_symbols - if not syms: - return _ex - - cdef Basic _x - if x is None: - _x = list(syms)[0] - else: - _x = sympify(x) - require(_x, Symbol) - if not _x in syms: - return _ex - - if x0 != 0: - _ex = _ex.subs({_x: _x + x0}) - - cdef RCP[const symengine.Symbol] X = symengine.rcp_static_cast_Symbol(_x.thisptr) - cdef umap_int_basic umap - cdef umap_int_basic_iterator iter, iterend - - if not as_deg_coef_pair: - b = c2py(deref(symengine.series(_ex.thisptr, X, n)).as_basic()) - if x0 != 0: - b = b.subs({_x: _x - x0}) - return b - - umap = deref(symengine.series(_ex.thisptr, X, n)).as_dict() - - iter = umap.begin() - iterend = umap.end() - poly = 0 - l = [] - while iter != iterend: - l.append([deref(iter).first, c2py((deref(iter).second))]) - inc(iter) - if as_deg_coef_pair: - return l - return add(*l) - - -cdef class Expr(Basic): - pass - - -cdef class Symbol(Expr): - """ - Symbol is a class to store a symbolic variable with a given name. - Subclassing Symbol leads to a memory leak due to a cycle in reference counting. - To avoid this with a performance penalty, set the kwarg store_pickle=True - in the constructor and support the pickle protocol in the subclass by - implmenting __reduce__. - """ - - def __init__(Basic self, name, *args, **kwargs): - cdef cppbool store_pickle; - if type(self) == Symbol: - self.thisptr = symengine.make_rcp_Symbol(name.encode("utf-8")) - else: - store_pickle = kwargs.pop("store_pickle", False) - if store_pickle: - # First set the pointer to a regular symbol so that when pickle.dumps - # is called when the PySymbol is created, methods like name works. - self.thisptr = symengine.make_rcp_Symbol(name.encode("utf-8")) - self.thisptr = symengine.make_rcp_PySymbol(name.encode("utf-8"), self, - store_pickle) - - def _sympy_(self): - import sympy - return sympy.Symbol(str(self)) - - def __reduce__(self): - if type(self) == Symbol: - return Basic.__reduce__(self) - else: - raise NotImplementedError("pickling for Symbol subclass not implemented") - - def _sage_(self): - import sage.all as sage - return sage.SR.symbol(str(self)) - - @property - def name(self): - return self.__str__() - - @property - def is_Atom(self): - return True - - @property - def is_Symbol(self): - return True - - @property - def is_symbol(self): - return True - - @property - def is_commutative(self): - return True - - @property - def func(self): - return self.__class__ - - -cdef class Dummy(Symbol): - - def __init__(Basic self, name=None, *args, **kwargs): - if name is None: - self.thisptr = symengine.make_rcp_Dummy() - else: - self.thisptr = symengine.make_rcp_Dummy(name.encode("utf-8")) - - def _sympy_(self): - import sympy - return sympy.Dummy(str(self)[1:]) - - @property - def is_Dummy(self): - return True - - @property - def func(self): - return self.__class__ - - -def symarray(prefix, shape, **kwargs): - """ Creates an nd-array of symbols - - Parameters - ---------- - prefix: str - shape: tuple - \*\*kwargs: - Passed on to :class:`Symbol`. - - Notes - ----- - This function requires NumPy. - - """ - arr = np.empty(shape, dtype=object) - for index in np.ndindex(shape): - arr[index] = Symbol('%s_%s' % (prefix, '_'.join(map(str, index))), **kwargs) - return arr - - -cdef class Constant(Expr): - - def __cinit__(self, name = None): - if name is None: - return - self.thisptr = symengine.make_rcp_Constant(name.encode("utf-8")) - - @property - def is_number(self): - return True - - def _sympy_(self): - raise Exception("Unknown Constant") - - def _sage_(self): - raise Exception("Unknown Constant") - - -cdef class ImaginaryUnit(Complex): - - def __cinit__(Basic self): - self.thisptr = symengine.I - - def as_powers_dict(self): - d = collections.defaultdict(int) - d[minus_one] = half - return d - -I = ImaginaryUnit() - - -cdef class Pi(Constant): - - def __cinit__(Basic self): - self.thisptr = symengine.pi - - def _sympy_(self): - import sympy - return sympy.pi - - def _sage_(self): - import sage.all as sage - return sage.pi - -pi = Pi() - - -cdef class Exp1(Constant): - - def __cinit__(Basic self): - self.thisptr = symengine.E - - def _sympy_(self): - import sympy - return sympy.E - - def _sage_(self): - import sage.all as sage - return sage.e - -E = Exp1() - - -cdef class GoldenRatio(Constant): - - def __cinit__(Basic self): - self.thisptr = symengine.GoldenRatio - - def _sympy_(self): - import sympy - return sympy.GoldenRatio - - def _sage_(self): - import sage.all as sage - return sage.golden_ratio - -golden_ratio = GoldenRatio() - - -cdef class Catalan(Constant): - - def __cinit__(Basic self): - self.thisptr = symengine.Catalan - - def _sympy_(self): - import sympy - return sympy.Catalan - - def _sage_(self): - import sage.all as sage - return sage.catalan - -catalan = Catalan() - - -cdef class EulerGamma(Constant): - - def __cinit__(Basic self): - self.thisptr = symengine.EulerGamma - - def _sympy_(self): - import sympy - return sympy.EulerGamma - - def _sage_(self): - import sage.all as sage - return sage.euler_gamma - -eulergamma = EulerGamma() - - -cdef class Boolean(Expr): - - def logical_not(self): - return c2py((deref(symengine.rcp_static_cast_Boolean(self.thisptr)).logical_not())) - - def __bool__(self): - raise TypeError("cannot determine truth value of Boolean") - - -cdef class BooleanAtom(Boolean): - - @property - def is_Boolean(self): - return True - - @property - def is_Atom(self): - return True - - -cdef class BooleanTrue(BooleanAtom): - - def __cinit__(Basic self): - self.thisptr = symengine.boolTrue - - def _sympy_(self): - import sympy - return sympy.S.true - - def _sage_(self): - return True - - def __bool__(self): - return True - - -true = BooleanTrue() - - -cdef class BooleanFalse(BooleanAtom): - - def __cinit__(Basic self): - self.thisptr = symengine.boolFalse - - def _sympy_(self): - import sympy - return sympy.S.false - - def _sage_(self): - return False - - def __nonzero__(self): - return False - - def __bool__(self): - return False - -false = BooleanFalse() - - -class And(Boolean): - - def __new__(cls, *args): - return logical_and(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.And(*s) - - -class Or(Boolean): - - def __new__(cls, *args): - return logical_or(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.Or(*s) - - -class Not(Boolean): - - def __new__(cls, x): - return logical_not(x) - - def _sympy_(self): - import sympy - s = self.args_as_sympy()[0] - return sympy.Not(s) - - -class Xor(Boolean): - - def __new__(cls, *args): - return logical_xor(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.Xor(*s) - - -class Relational(Boolean): - - @property - def is_Relational(self): - return True - - def __bool__(self): - raise TypeError("cannot determine truth value of Relational") - - -Rel = Relational - - -class Equality(Relational): - - def __new__(cls, *args): - return eq(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.Equality(*s) - - def _sage_(self): - import sage.all as sage - s = self.args_as_sage() - return sage.eq(*s) - - @property - def is_Equality(self): - return True - - @property - def func(self): - return self.__class__ - - -Eq = Equality - - -class Unequality(Relational): - - def __new__(cls, *args): - return ne(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.Unequality(*s) - - def _sage_(self): - import sage.all as sage - s = self.args_as_sage() - return sage.ne(*s) - - @property - def func(self): - return self.__class__ - - -Ne = Unequality - - -class LessThan(Relational): - - def __new__(cls, *args): - return le(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.LessThan(*s) - - def _sage_(self): - import sage.all as sage - s = self.args_as_sage() - return sage.le(*s) - - -Le = LessThan - - -class StrictLessThan(Relational): - - def __new__(cls, *args): - return lt(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.StrictLessThan(*s) - - def _sage_(self): - import sage.all as sage - s = self.args_as_sage() - return sage.lt(*s) - - -Lt = StrictLessThan - - -cdef class Number(Expr): - @property - def is_Atom(self): - return True - - @property - def is_Number(self): - return True - - @property - def is_number(self): - return True - - @property - def is_commutative(self): - return True - - @property - def is_positive(Basic self): - return deref(symengine.rcp_static_cast_Number(self.thisptr)).is_positive() - - @property - def is_negative(Basic self): - return deref(symengine.rcp_static_cast_Number(self.thisptr)).is_negative() - - @property - def is_nonzero(self): - return not (self.is_complex or self.is_zero) - - @property - def is_nonnegative(self): - return not (self.is_complex or self.is_negative) - - @property - def is_nonpositive(self): - return not (self.is_complex or self.is_positive) - - @property - def is_complex(Basic self): - return deref(symengine.rcp_static_cast_Number(self.thisptr)).is_complex() - - @property - def real(self): - return self - - @property - def imag(self): - return S.Zero - - -class Rational(Number): - - def __new__(cls, p, q): - p = int(p) - q = int(q) - cdef int p_ - cdef int q_ - cdef symengine.integer_class p__ - cdef symengine.integer_class q__ - cdef string tmp - try: - # Try to convert p and q to int - p_ = p - q_ = q - return c2py(symengine.Rational.from_two_ints(p_, q_)); - except OverflowError: - # Too big, need to use mpz - tmp = hex(p).encode("utf-8") - symengine.mp_set_str(p__, tmp) - tmp = hex(q).encode("utf-8") - symengine.mp_set_str(q__, tmp) - return c2py(symengine.Integer(p__).divint(symengine.Integer(q__))) - - @property - def is_Rational(self): - return True - - @property - def is_rational(self): - return True - - @property - def is_real(self): - return True - - @property - def is_finite(self): - return True - - @property - def is_integer(self): - return False - - @property - def p(self): - return self.get_num_den()[0] - - @property - def q(self): - return self.get_num_den()[1] - - def get_num_den(Basic self): - cdef RCP[const symengine.Integer] _num, _den - symengine.get_num_den(deref(symengine.rcp_static_cast_Rational(self.thisptr)), - symengine.outArg_Integer(_num), symengine.outArg_Integer(_den)) - return [c2py(_num), c2py(_den)] - - def _sympy_(self): - rat = self.get_num_den() - return rat[0]._sympy_() / rat[1]._sympy_() - - def _sage_(self): - try: - from sage.symbolic.symengine_conversions import convert_to_rational - return convert_to_rational(self) - except ImportError: - rat = self.get_num_den() - return rat[0]._sage_() / rat[1]._sage_() - - @property - def func(self): - return self.__class__ - - -class Integer(Rational): - - def __new__(cls, i): - i = int(i) - cdef int i_ - cdef symengine.integer_class i__ - cdef string tmp - try: - # Try to convert "i" to int - i_ = i - int_ok = True - except OverflowError: - # Too big, need to use mpz - int_ok = False - tmp = hex(i).encode("utf-8") - symengine.mp_set_str(i__, tmp) - # Note: all other exceptions are left intact - if int_ok: - return c2py(symengine.integer(i_)) - else: - return c2py(symengine.integer(i__)) - - @property - def is_Integer(self): - return True - - @property - def is_integer(self): - return True - - def doit(self, **hints): - return self - - def __hash__(Basic self): - return deref(self.thisptr).hash() - - def __richcmp__(a, b, int op): - A = _sympify(a, False) - B = _sympify(b, False) - if not (isinstance(A, Integer) and isinstance(B, Integer)): - if (op == 2): - return False - elif (op == 3): - return True - return NotImplemented - return Integer._richcmp_(A, B, op) - - def _richcmp_(Basic A, Basic B, int op): - cdef int i = deref(symengine.rcp_static_cast_Integer(A.thisptr)).compare(deref(symengine.rcp_static_cast_Integer(B.thisptr))) - if (op == 0): - return i < 0 - elif (op == 1): - return i <= 0 - elif (op == 2): - return i == 0 - elif (op == 3): - return i != 0 - elif (op == 4): - return i > 0 - elif (op == 5): - return i >= 0 - else: - return NotImplemented - - def _sympy_(Basic self): - import sympy - return sympy.Integer(int(self)) - - def _sage_(Basic self): - try: - from sage.symbolic.symengine_conversions import convert_to_integer - return convert_to_integer(self) - except ImportError: - import sage.all as sage - return sage.Integer(str(self)) - - def __int__(Basic self): - cdef string s = symengine.mp_get_hex_str( - deref(symengine.rcp_static_cast_Integer(self.thisptr)).as_integer_class()) - return int(s.decode("utf-8"), base=16) - - @property - def p(self): - return int(self) - - @property - def q(self): - return 1 - - def get_num_den(Basic self): - return self, 1 - - @property - def func(self): - return self.__class__ - - -def dps_to_prec(n): - """Return the number of bits required to represent n decimals accurately.""" - return max(1, int(round((int(n)+1)*3.3219280948873626))) - - -class BasicMeta(type): - def __instancecheck__(self, instance): - return isinstance(instance, self._classes) - -class Float(Number): - - @property - def is_rational(self): - return None - - @property - def is_irrational(self): - return None - - @property - def is_real(self): - return True - - @property - def is_Float(self): - return True - - def __new__(cls, num, dps=None, precision=None): - if cls is not Float: - return super(Float, cls).__new__(cls) - - if dps is not None and precision is not None: - raise ValueError('Both decimal and binary precision supplied. ' - 'Supply only one. ') - if dps is None and precision is None: - dps = 15 - if precision is None: - precision = dps_to_prec(dps) - - IF HAVE_SYMENGINE_MPFR: - if precision > 53: - if isinstance(num, RealMPFR) and precision == num.get_prec(): - return num - return RealMPFR(str(num), precision) - if precision > 53: - raise ValueError('RealMPFR unavailable for high precision numerical values.') - elif isinstance(num, RealDouble): - return num - else: - return RealDouble(float(num)) - - -RealNumber = Float - - -class RealDouble(Float): - - def __new__(cls, i): - cdef double i_ = i - return c2py(symengine.make_rcp_RealDouble(i_)) - - def _sympy_(Basic self): - import sympy - return sympy.Float(float(self)) - - def _sage_(Basic self): - import sage.all as sage - return sage.RealDoubleField()(float(self)) - - def __float__(Basic self): - return deref(symengine.rcp_static_cast_RealDouble(self.thisptr)).as_double() - - def __complex__(self): - return complex(float(self)) - - -cdef class ComplexBase(Number): - - def real_part(Basic self): - return c2py(deref(symengine.rcp_static_cast_ComplexBase(self.thisptr)).real_part()) - - def imaginary_part(Basic self): - return c2py(deref(symengine.rcp_static_cast_ComplexBase(self.thisptr)).imaginary_part()) - - @property - def real(self): - return self.real_part() - - @property - def imag(self): - return self.imaginary_part() - - -cdef class ComplexDouble(ComplexBase): - - def __cinit__(self, i = None): - if i is None: - return - cdef double complex i_ = i - self.thisptr = symengine.make_rcp_ComplexDouble(i_) - - def _sympy_(self): - import sympy - return self.real_part()._sympy_() + sympy.I * self.imaginary_part()._sympy_() - - def _sage_(self): - import sage.all as sage - return self.real_part()._sage_() + sage.I * self.imaginary_part()._sage_() - - def __complex__(Basic self): - return deref(symengine.rcp_static_cast_ComplexDouble(self.thisptr)).as_complex_double() - - -class RealMPFR(Float): - - IF HAVE_SYMENGINE_MPFR: - def __new__(cls, i = None, long prec = 53, unsigned base = 10): - if i is None: - return - cdef string i_ = str(i).encode("utf-8") - cdef symengine.mpfr_class m - m = symengine.mpfr_class(i_, prec, base) - return c2py(symengine.real_mpfr(move[symengine.mpfr_class](m))) - - def get_prec(Basic self): - return Integer(deref(symengine.rcp_static_cast_RealMPFR(self.thisptr)).get_prec()) - - def _sympy_(self): - import sympy - cdef long prec_ = self.get_prec() - prec = max(1, int(round(prec_/3.3219280948873626)-1)) - return sympy.Float(str(self), prec) - - def _sage_(self): - try: - from sage.symbolic.symengine_conversions import convert_to_real_number - return convert_to_real_number(self) - except ImportError: - import sage.all as sage - return sage.RealField(int(self.get_prec()))(str(self)) - ELSE: - pass - - -cdef class ComplexMPC(ComplexBase): - IF HAVE_SYMENGINE_MPC: - def __cinit__(self, i = None, j = 0, long prec = 53, unsigned base = 10): - if i is None: - return - cdef string i_ = ("(" + str(i) + " " + str(j) + ")").encode("utf-8") - cdef symengine.mpc_class m = symengine.mpc_class(i_, prec, base) - self.thisptr = symengine.complex_mpc(move[symengine.mpc_class](m)) - - def _sympy_(self): - import sympy - return self.real_part()._sympy_() + sympy.I * self.imaginary_part()._sympy_() - - def _sage_(self): - try: - from sage.symbolic.symengine_conversions import convert_to_mpcomplex_number - return convert_to_mpcomplex_number(self) - except ImportError: - import sage.all as sage - return sage.MPComplexField(int(self.get_prec()))(str(self.real_part()), str(self.imaginary_part())) - ELSE: - pass - - -cdef class Complex(ComplexBase): - - def _sympy_(self): - import sympy - return self.real_part()._sympy_() + sympy.I * self.imaginary_part()._sympy_() - - def _sage_(self): - import sage.all as sage - return self.real_part()._sage_() + sage.I * self.imaginary_part()._sage_() - - -cdef class Infinity(Number): - - @property - def is_infinite(self): - return True - - def __cinit__(Basic self): - self.thisptr = symengine.Inf - - def _sympy_(self): - import sympy - return sympy.oo - - def _sage_(self): - import sage.all as sage - return sage.oo - -oo = Infinity() - - -cdef class NegativeInfinity(Number): - - @property - def is_infinite(self): - return True - - def __cinit__(Basic self): - self.thisptr = symengine.neg(symengine.Inf) - - def _sympy_(self): - import sympy - return -sympy.oo - - def _sage_(self): - import sage.all as sage - return -sage.oo - - def as_powers_dict(self): - d = collections.defaultdict(int) - d[minus_one] = 1 - d[oo] = 1 - return d - - -minus_oo = NegativeInfinity() - - -cdef class ComplexInfinity(Number): - - @property - def is_infinite(self): - return True - - def __cinit__(Basic self): - self.thisptr = symengine.ComplexInf - - def _sympy_(self): - import sympy - return sympy.zoo - - def _sage_(self): - import sage.all as sage - return sage.unsigned_infinity - -zoo = ComplexInfinity() - - -cdef class NaN(Number): - - @property - def is_rational(self): - return None - - @property - def is_integer(self): - return None - - @property - def is_real(self): - return None - - @property - def is_finite(self): - return None - - def __cinit__(Basic self): - self.thisptr = symengine.Nan - - def _sympy_(self): - import sympy - return sympy.nan - - def _sage_(self): - import sage.all as sage - return sage.NaN - -nan = NaN() - - -class Zero(Integer): - def __new__(cls): - cdef Basic r = Number.__new__(Zero) - r.thisptr = symengine.integer(0) - return r - -zero = Zero() - - -class One(Integer): - def __new__(cls): - cdef Basic r = Number.__new__(One) - r.thisptr = symengine.integer(1) - return r - -one = One() - - -class NegativeOne(Integer): - def __new__(cls): - cdef Basic r = Number.__new__(NegativeOne) - r.thisptr = symengine.integer(-1) - return r - -minus_one = NegativeOne() - - -class Half(Rational): - def __new__(cls): - cdef Basic q = Number.__new__(Half) - q.thisptr = symengine.rational(1, 2) - return q - -half = Half() - - -class AssocOp(Expr): - - @classmethod - def make_args(cls, expr): - if isinstance(expr, cls): - return expr.args - else: - return (sympify(expr),) - - -class Add(AssocOp): - - identity = 0 - - def __new__(cls, *args, **kwargs): - cdef symengine.vec_basic v_ = iter_to_vec_basic(args) - return c2py(symengine.add(v_)) - - @classmethod - def _from_args(self, args): - if len(args) == 0: - return self.identity - elif len(args) == 1: - return args[0] - - return Add(*args) - - @property - def is_Add(self): - return True - - def _sympy_(self): - from sympy import Add - return Add(*self.args) - - def _sage_(Basic self): - cdef RCP[const symengine.Add] X = symengine.rcp_static_cast_Add(self.thisptr) - cdef rcp_const_basic a, b - deref(X).as_two_terms(symengine.outArg(a), symengine.outArg(b)) - return c2py(a)._sage_() + c2py(b)._sage_() - - @property - def func(self): - return self.__class__ - - def as_coefficients_dict(Basic self): - cdef RCP[const symengine.Add] X = symengine.rcp_static_cast_Add(self.thisptr) - cdef umap_basic_num umap - cdef umap_basic_num_iterator iter, iterend - d = collections.defaultdict(int) - d[Integer(1)] = c2py((deref(X).get_coef())) - umap = deref(X).get_dict() - iter = umap.begin() - iterend = umap.end() - while iter != iterend: - d[c2py((deref(iter).first))] =\ - c2py((deref(iter).second)) - inc(iter) - return d - - -class Mul(AssocOp): - - identity = 1 - - def __new__(cls, *args, **kwargs): - cdef symengine.vec_basic v_ = iter_to_vec_basic(args) - return c2py(symengine.mul(v_)) - - @classmethod - def _from_args(self, args): - if len(args) == 0: - return self.identity - elif len(args) == 1: - return args[0] - - return Mul(*args) - - @property - def is_Mul(self): - return True - - def _sympy_(self): - from sympy import Mul - return Mul(*self.args) - - def _sage_(Basic self): - cdef RCP[const symengine.Mul] X = symengine.rcp_static_cast_Mul(self.thisptr) - cdef rcp_const_basic a, b - deref(X).as_two_terms(symengine.outArg(a), symengine.outArg(b)) - return c2py(a)._sage_() * c2py(b)._sage_() - - @property - def func(self): - return self.__class__ - - def as_coefficients_dict(Basic self): - cdef RCP[const symengine.Mul] X = symengine.rcp_static_cast_Mul(self.thisptr) - cdef RCP[const symengine.Integer] one = symengine.integer(1) - cdef map_basic_basic dict = deref(X).get_dict() - d = collections.defaultdict(int) - d[c2py(symengine.mul_from_dict(\ - (one), - move[symengine.map_basic_basic](dict)))] =\ - c2py(deref(X).get_coef()) - return d - - def as_powers_dict(Basic self): - cdef RCP[const symengine.Mul] X = symengine.rcp_static_cast_Mul(self.thisptr) - cdef map_basic_basic m = deref(X).get_dict() - coef = c2py((deref(X).get_coef())) - if coef == 1: - d = collections.defaultdict(int) - else: - d = coef.as_powers_dict() - - it = m.begin() - it_end = m.end() - while it != it_end: - base = c2py((deref(it).first)) - exp = c2py((deref(it).second)) - if base.is_Rational and base.p < base.q and base.p > 0: - d[1/base] -= exp - else: - d[base] += exp - inc(it) - - return d - - -class Pow(Expr): - - def __new__(cls, a, b): - return _sympify(a) ** b - - @property - def base(Basic self): - cdef RCP[const symengine.Pow] X = symengine.rcp_static_cast_Pow(self.thisptr) - return c2py(deref(X).get_base()) - - @property - def exp(Basic self): - cdef RCP[const symengine.Pow] X = symengine.rcp_static_cast_Pow(self.thisptr) - return c2py(deref(X).get_exp()) - - def as_base_exp(self): - return self.base, self.exp - - @property - def is_Pow(self): - return True - - @property - def is_commutative(self): - return (self.base.is_commutative and self.exp.is_commutative) - - def _sympy_(Basic self): - cdef RCP[const symengine.Pow] X = symengine.rcp_static_cast_Pow(self.thisptr) - base = c2py(deref(X).get_base()) - exp = c2py(deref(X).get_exp()) - return base._sympy_() ** exp._sympy_() - - def _sage_(Basic self): - cdef RCP[const symengine.Pow] X = symengine.rcp_static_cast_Pow(self.thisptr) - base = c2py(deref(X).get_base()) - exp = c2py(deref(X).get_exp()) - return base._sage_() ** exp._sage_() - - @property - def func(self): - return self.__class__ - - def as_powers_dict(Basic self): - d = collections.defaultdict(int) - base, exp = self.as_base_exp() - if base.is_Rational and base.p < base.q and base.p > 0: - d[1/base] = -exp - else: - d[base] = exp - return d - - -class Function(Expr): - - def __new__(cls, *args, **kwargs): - if cls == Function: - nargs = len(args) - if nargs == 0: - raise TypeError("Required at least one argument to Function") - elif nargs == 1: - return UndefFunction(args[0]) - elif nargs > 1: - raise TypeError(f"Unexpected extra arguments {args[1:]}.") - - return super(Function, cls).__new__(cls) - - @property - def is_Function(self): - return True - - def func(self, *values): - import sys - return getattr(sys.modules[__name__], self.__class__.__name__.lower())(*values) - - -class OneArgFunction(Function): - - def get_arg(Basic self): - cdef RCP[const symengine.OneArgFunction] X = symengine.rcp_static_cast_OneArgFunction(self.thisptr) - return c2py(deref(X).get_arg()) - - def _sympy_(self): - import sympy - return getattr(sympy, self.__class__.__name__)(self.get_arg()._sympy_()) - - def _sage_(self): - import sage.all as sage - return getattr(sage, self.__class__.__name__.lower())(self.get_arg()._sage_()) - - -class HyperbolicFunction(OneArgFunction): - pass - -class TrigFunction(OneArgFunction): - pass - -class gamma(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.gamma(X.thisptr)) - -class LambertW(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.lambertw(X.thisptr)) - - def _sage_(self): - import sage.all as sage - return sage.lambert_w(self.get_arg()._sage_()) - -class zeta(Function): - def __new__(cls, s, a = None): - cdef Basic S = sympify(s) - if a == None: - return c2py(symengine.zeta(S.thisptr)) - cdef Basic A = sympify(a) - return c2py(symengine.zeta(S.thisptr, A.thisptr)) - - def _sympy_(self): - import sympy - return sympy.zeta(*self.args_as_sympy()) - -class dirichlet_eta(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.dirichlet_eta(X.thisptr)) - -class KroneckerDelta(Function): - def __new__(cls, x, y): - cdef Basic X = sympify(x) - cdef Basic Y = sympify(y) - return c2py(symengine.kronecker_delta(X.thisptr, Y.thisptr)) - - def _sympy_(self): - import sympy - return sympy.KroneckerDelta(*self.args_as_sympy()) - - def _sage_(self): - import sage.all as sage - return sage.kronecker_delta(*self.args_as_sage()) - -class LeviCivita(Function): - def __new__(cls, *args): - cdef symengine.vec_basic v = iter_to_vec_basic(args) - return c2py(symengine.levi_civita(v)) - - def _sympy_(self): - import sympy - return sympy.LeviCivita(*self.args_as_sympy()) - -class erf(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.erf(X.thisptr)) - -class erfc(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.erfc(X.thisptr)) - -class lowergamma(Function): - def __new__(cls, x, y): - cdef Basic X = sympify(x) - cdef Basic Y = sympify(y) - return c2py(symengine.lowergamma(X.thisptr, Y.thisptr)) - - def _sympy_(self): - import sympy - return sympy.lowergamma(*self.args_as_sympy()) - - def _sage_(self): - import sage.all as sage - return sage.gamma_inc_lower(*self.args_as_sage()) - -class uppergamma(Function): - def __new__(cls, x, y): - cdef Basic X = sympify(x) - cdef Basic Y = sympify(y) - return c2py(symengine.uppergamma(X.thisptr, Y.thisptr)) - - def _sympy_(self): - import sympy - return sympy.uppergamma(*self.args_as_sympy()) - - def _sage_(self): - import sage.all as sage - return sage.gamma_inc(*self.args_as_sage()) - -class loggamma(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.loggamma(X.thisptr)) - - def _sage_(self): - import sage.all as sage - return sage.log_gamma(self.get_arg()._sage_()) - -class beta(Function): - def __new__(cls, x, y): - cdef Basic X = sympify(x) - cdef Basic Y = sympify(y) - return c2py(symengine.beta(X.thisptr, Y.thisptr)) - - def _sympy_(self): - import sympy - return sympy.beta(*self.args_as_sympy()) - - def _sage_(self): - import sage.all as sage - return sage.beta(*self.args_as_sage()) - -class polygamma(Function): - def __new__(cls, x, y): - cdef Basic X = sympify(x) - cdef Basic Y = sympify(y) - return c2py(symengine.polygamma(X.thisptr, Y.thisptr)) - - def _sympy_(self): - import sympy - return sympy.polygamma(*self.args_as_sympy()) - -class sign(OneArgFunction): - - @property - def is_complex(self): - return True - - @property - def is_finite(self): - return True - - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.sign(X.thisptr)) - -class floor(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.floor(X.thisptr)) - -class ceiling(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.ceiling(X.thisptr)) - - def _sage_(self): - import sage.all as sage - return sage.ceil(self.get_arg()._sage_()) - -class conjugate(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.conjugate(X.thisptr)) - -class log(OneArgFunction): - def __new__(cls, x, y=None): - cdef Basic X = sympify(x) - if y == None: - return c2py(symengine.log(X.thisptr)) - cdef Basic Y = sympify(y) - return c2py(symengine.log(X.thisptr, Y.thisptr)) - -class sin(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.sin(X.thisptr)) - -class cos(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.cos(X.thisptr)) - -class tan(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.tan(X.thisptr)) - -class cot(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.cot(X.thisptr)) - -class sec(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.sec(X.thisptr)) - -class csc(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.csc(X.thisptr)) - -class asin(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.asin(X.thisptr)) - -class acos(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.acos(X.thisptr)) - -class atan(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.atan(X.thisptr)) - -class acot(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.acot(X.thisptr)) - -class asec(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.asec(X.thisptr)) - -class acsc(TrigFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.acsc(X.thisptr)) - -class sinh(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.sinh(X.thisptr)) - -class cosh(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.cosh(X.thisptr)) - -class tanh(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.tanh(X.thisptr)) - -class coth(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.coth(X.thisptr)) - -class sech(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.sech(X.thisptr)) - -class csch(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.csch(X.thisptr)) - -class asinh(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.asinh(X.thisptr)) - -class acosh(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.acosh(X.thisptr)) - -class atanh(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.atanh(X.thisptr)) - -class acoth(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.acoth(X.thisptr)) - -class asech(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.asech(X.thisptr)) - -class acsch(HyperbolicFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.acsch(X.thisptr)) - -class atan2(Function): - def __new__(cls, x, y): - cdef Basic X = sympify(x) - cdef Basic Y = sympify(y) - return c2py(symengine.atan2(X.thisptr, Y.thisptr)) - - def _sympy_(self): - import sympy - return sympy.atan2(*self.args_as_sympy()) - - def _sage_(self): - import sage.all as sage - return sage.atan2(*self.args_as_sage()) - -# For backwards compatibility - -Sin = sin -Cos = cos -Tan = tan -Cot = cot -Sec = sec -Csc = csc -ASin = asin -ACos = acos -ATan = atan -ACot = acot -ASec = asec -ACsc = acsc -Sinh = sinh -Cosh = cosh -Tanh = tanh -Coth = coth -Sech = sech -Csch = csch -ASinh = asinh -ACosh = acosh -ATanh = atanh -ACoth = acoth -ASech = asech -ACsch = acsch -ATan2 = atan2 -Log = log -Gamma = gamma - -add = Add -mul = Mul - - -class UnevaluatedExpr(OneArgFunction): - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.unevaluated_expr(X.thisptr)) - - @property - def is_number(self): - return self.args[0].is_number - - @property - def is_integer(self): - return self.args[0].is_integer - - @property - def is_finite(self): - return self.args[0].is_finite - - -class Abs(OneArgFunction): - - @property - def is_real(self): - return True - - @property - def is_negative(self): - return False - - def __new__(cls, x): - cdef Basic X = sympify(x) - return c2py(symengine.abs(X.thisptr)) - - def _sympy_(Basic self): - cdef RCP[const symengine.Abs] X = symengine.rcp_static_cast_Abs(self.thisptr) - arg = c2py(deref(X).get_arg())._sympy_() - return abs(arg) - - def _sage_(Basic self): - cdef RCP[const symengine.Abs] X = symengine.rcp_static_cast_Abs(self.thisptr) - arg = c2py(deref(X).get_arg())._sage_() - return abs(arg) - - @property - def func(self): - return self.__class__ - -class FunctionSymbol(Function): - - def get_name(Basic self): - cdef RCP[const symengine.FunctionSymbol] X = \ - symengine.rcp_static_cast_FunctionSymbol(self.thisptr) - name = deref(X).get_name().decode("utf-8") - return str(name) - - @property - def name(Basic self): - return self.get_name() - - def _sympy_(self): - import sympy - name = self.get_name() - return sympy.Function(name)(*self.args_as_sympy()) - - def _sage_(self): - import sage.all as sage - name = self.get_name() - return sage.function(name)(*self.args_as_sage()) - - def func(self, *values): - name = self.get_name() - return function_symbol(name, *values) - - -class UndefFunction(object): - def __init__(self, name): - self.name = name - - def __call__(self, *values): - return function_symbol(self.name, *values) - - -cdef rcp_const_basic pynumber_to_symengine(PyObject* o1): - cdef Basic X = sympify(o1) - return X.thisptr - -cdef PyObject* symengine_to_sage(rcp_const_basic o1): - import sage.all as sage - t = c2py(o1)._sage_() - Py_XINCREF(t) - return (t) - -cdef PyObject* symengine_to_sympy(rcp_const_basic o1): - t = c2py(o1)._sympy_() - Py_XINCREF(t) - return (t) - -cdef RCP[const symengine.Number] sympy_eval(PyObject* o1, long bits): - prec = max(1, int(round(bits/3.3219280948873626)-1)) - cdef Number X = sympify((o1).n(prec)) - return symengine.rcp_static_cast_Number(X.thisptr) - -cdef RCP[const symengine.Number] sage_eval(PyObject* o1, long bits): - cdef Number X = sympify((o1).n(bits)) - return symengine.rcp_static_cast_Number(X.thisptr) - -cdef rcp_const_basic sage_diff(PyObject* o1, rcp_const_basic symbol): - cdef Basic X = sympify((o1).diff(c2py(symbol)._sage_())) - return X.thisptr - -cdef rcp_const_basic sympy_diff(PyObject* o1, rcp_const_basic symbol): - cdef Basic X = sympify((o1).diff(c2py(symbol)._sympy_())) - return X.thisptr - -def create_sympy_module(): - cdef PyModule s = PyModule.__new__(PyModule) - s.thisptr = symengine.make_rcp_PyModule(&symengine_to_sympy, &pynumber_to_symengine, &sympy_eval, - &sympy_diff) - return s - -def create_sage_module(): - cdef PyModule s = PyModule.__new__(PyModule) - s.thisptr = symengine.make_rcp_PyModule(&symengine_to_sage, &pynumber_to_symengine, &sage_eval, - &sage_diff) - return s - -sympy_module = create_sympy_module() -sage_module = create_sage_module() - -cdef class PyNumber(Number): - def __cinit__(self, obj = None, PyModule module = None): - if obj is None: - return - Py_XINCREF((obj)) - self.thisptr = symengine.make_rcp_PyNumber((obj), module.thisptr) - - def _sympy_(self): - import sympy - return sympy.sympify(self.pyobject()) - - def _sage_(self): - import sage.all as sage - res = self.pyobject() - if hasattr(res, '_sage_'): - return res._sage_() - return res - - def pyobject(self): - return deref(symengine.rcp_static_cast_PyNumber(self.thisptr)).get_py_object() - - -class PyFunction(FunctionSymbol): - - def __init__(Basic self, pyfunction = None, args = None, pyfunction_class=None, module=None): - if pyfunction is None: - return - cdef symengine.vec_basic v = iter_to_vec_basic(args) - cdef PyFunctionClass _pyfunction_class = get_function_class(pyfunction_class, module) - cdef PyObject* _pyfunction = pyfunction - Py_XINCREF(_pyfunction) - self.thisptr = symengine.make_rcp_PyFunction(v, _pyfunction_class.thisptr, _pyfunction) - - def _sympy_(self): - import sympy - return sympy.sympify(self.pyobject()) - - def _sage_(self): - import sage.all as sage - return sage.SR(self.pyobject()) - - def pyobject(Basic self): - return deref(symengine.rcp_static_cast_PyFunction(self.thisptr)).get_py_object() - -cdef class PyFunctionClass(object): - - def __cinit__(self, function, PyModule module not None): - self.thisptr = symengine.make_rcp_PyFunctionClass((function), str(function).encode("utf-8"), - module.thisptr) - -# TODO: remove this once SymEngine conversions are available in Sage. -def wrap_sage_function(func): - return PyFunction(func, func.operands(), func.operator(), sage_module) - - -class Max(Function): - - def __new__(cls, *args): - return _max(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.Max(*s) - - def _sage_(self): - import sage.all as sage - s = self.args_as_sage() - return sage.max(*s) - - @property - def func(self): - return self.__class__ - -class Min(Function): - - def __new__(cls, *args): - return _min(*args) - - def _sympy_(self): - import sympy - s = self.args_as_sympy() - return sympy.Min(*s) - - def _sage_(self): - import sage.all as sage - s = self.args_as_sage() - return sage.min(*s) - - @property - def func(self): - return self.__class__ - - -class Derivative(Expr): - - def __new__(self, expr, *variables): - if len(variables) == 1 and is_sequence(variables[0]): - return diff(expr, *variables[0]) - return diff(expr, *variables) - - @property - def is_Derivative(self): - return True - - @property - def expr(Basic self): - cdef RCP[const symengine.Derivative] X = symengine.rcp_static_cast_Derivative(self.thisptr) - return c2py(deref(X).get_arg()) - - @property - def variables(self): - return self.args[1:] - - def _sympy_(Basic self): - cdef RCP[const symengine.Derivative] X = \ - symengine.rcp_static_cast_Derivative(self.thisptr) - arg = c2py(deref(X).get_arg())._sympy_() - cdef symengine.multiset_basic Y = deref(X).get_symbols() - s = [] - for i in Y: - s.append(c2py((i))._sympy_()) - import sympy - return sympy.Derivative(arg, *s) - - def _sage_(Basic self): - cdef RCP[const symengine.Derivative] X = \ - symengine.rcp_static_cast_Derivative(self.thisptr) - arg = c2py(deref(X).get_arg())._sage_() - cdef symengine.multiset_basic Y = deref(X).get_symbols() - s = [] - for i in Y: - s.append(c2py((i))._sage_()) - return arg.diff(*s) - - @property - def func(self): - return self.__class__ - - -class Subs(Expr): - - def __new__(self, expr, variables, point): - return sympify(expr).subs(variables, point) - - @property - def expr(Basic self): - cdef RCP[const symengine.Subs] me = symengine.rcp_static_cast_Subs(self.thisptr) - return c2py(deref(me).get_arg()) - - @property - def variables(Basic self): - cdef RCP[const symengine.Subs] me = symengine.rcp_static_cast_Subs(self.thisptr) - cdef symengine.vec_basic variables = deref(me).get_variables() - return vec_basic_to_tuple(variables) - - @property - def point(Basic self): - cdef RCP[const symengine.Subs] me = symengine.rcp_static_cast_Subs(self.thisptr) - cdef symengine.vec_basic point = deref(me).get_point() - return vec_basic_to_tuple(point) - - def _sympy_(Basic self): - cdef RCP[const symengine.Subs] X = symengine.rcp_static_cast_Subs(self.thisptr) - arg = c2py(deref(X).get_arg())._sympy_() - cdef symengine.vec_basic V = deref(X).get_variables() - cdef symengine.vec_basic P = deref(X).get_point() - v = [] - p = [] - for i in range(V.size()): - v.append(c2py((V[i]))._sympy_()) - p.append(c2py((P[i]))._sympy_()) - import sympy - return sympy.Subs(arg, v, p) - - def _sage_(Basic self): - cdef RCP[const symengine.Subs] X = symengine.rcp_static_cast_Subs(self.thisptr) - arg = c2py(deref(X).get_arg())._sage_() - cdef symengine.vec_basic V = deref(X).get_variables() - cdef symengine.vec_basic P = deref(X).get_point() - v = {} - for i in range(V.size()): - v[c2py((V[i]))._sage_()] = \ - c2py((P[i]))._sage_() - return arg.subs(v) - - @property - def func(self): - return self.__class__ - - -class Piecewise(Function): - - def __new__(self, *args): - return piecewise(*args) - - def _sympy_(self): - import sympy - a = self.args - l = [] - for i in range(0, len(a), 2): - l.append((a[i]._sympy_(), a[i + 1]._sympy_())) - return sympy.Piecewise(*l) - - -cdef class Set(Expr): - - def intersection(self, a): - cdef Set other = sympify(a) - cdef RCP[const symengine.Set] other_ = symengine.rcp_static_cast_Set(other.thisptr) - return c2py((deref(symengine.rcp_static_cast_Set(self.thisptr)) - .set_intersection(other_))) - - def union(self, a): - cdef Set other = sympify(a) - cdef RCP[const symengine.Set] other_ = symengine.rcp_static_cast_Set(other.thisptr) - return c2py((deref(symengine.rcp_static_cast_Set(self.thisptr)) - .set_union(other_))) - - def complement(self, a): - cdef Set other = sympify(a) - cdef RCP[const symengine.Set] other_ = symengine.rcp_static_cast_Set(other.thisptr) - return c2py((deref(symengine.rcp_static_cast_Set(self.thisptr)) - .set_complement(other_))) - - def contains(self, a): - cdef Basic a_ = sympify(a) - return c2py((deref(symengine.rcp_static_cast_Set(self.thisptr)) - .contains(a_.thisptr))) - - -class Interval(Set): - - def __new__(self, *args, left_open=None, right_open=None): - list_args = list(args) - if ((left_open is not None) and (right_open is None)) or ((left_open is None) and (right_open is not None)): - raise ValueError("Both (or neither) keyword arguments for Interval should be specified") - if left_open is not None: - list_args.append(left_open) - if right_open is not None: - list_args.append(right_open) - return interval(*list_args) - - @property - def start(self): - return self.args[0] - - @property - def end(self): - return self.args[1] - - def _sympy_(self): - import sympy - return sympy.Interval(*[arg._sympy_() for arg in self.args]) - - -class EmptySet(Set): - - def __new__(self): - return emptyset() - - def _sympy_(self): - import sympy - return sympy.S.EmptySet - - @property - def func(self): - return self.__class__ - - -class Reals(Set): - - def __new__(self): - return reals() - - def _sympy_(self): - import sympy - return sympy.S.Reals - - @property - def func(self): - return self.__class__ - - -class Rationals(Set): - - def __new__(self): - return rationals() - - def _sympy_(self): - import sympy - return sympy.S.Rationals - - @property - def func(self): - return self.__class__ - - -class Integers(Set): - - def __new__(self): - return integers() - - def _sympy_(self): - import sympy - return sympy.S.Integers - - @property - def func(self): - return self.__class__ - - -class UniversalSet(Set): - - def __new__(self): - return universalset() - - def _sympy_(self): - import sympy - return sympy.S.UniversalSet - - @property - def func(self): - return self.__class__ - - -class FiniteSet(Set): - - def __new__(self, *args): - return finiteset(*args) - - def _sympy_(self): - import sympy - return sympy.FiniteSet(*[arg._sympy_() for arg in self.args]) - - -class Contains(Boolean): - - def __new__(self, expr, sset): - return contains(expr, sset) - - def _sympy_(self): - import sympy - return sympy.Contains(*[arg._sympy_() for arg in self.args]) - - -class Union(Set): - - def __new__(self, *args): - return set_union(*args) - - def _sympy_(self): - import sympy - return sympy.Union(*[arg._sympy_() for arg in self.args]) - - -class Complement(Set): - - def __new__(self, universe, container): - return set_complement(universe, container) - - def _sympy_(self): - import sympy - return sympy.Complement(*[arg._sympy_() for arg in self.args]) - - -class ConditionSet(Set): - - def __new__(self, sym, condition): - return conditionset(sym, condition) - - -class ImageSet(Set): - - def __new__(self, sym, expr, base): - return imageset(sym, expr, base) - - - -cdef class MatrixBase: - - @property - def is_Matrix(self): - return True - - def __richcmp__(a, b, int op): - A = _sympify(a, False) - B = _sympify(b, False) - if not (isinstance(A, MatrixBase) and isinstance(B, MatrixBase)): - if (op == 2): - return False - elif (op == 3): - return True - return NotImplemented - return A._richcmp_(B, op) - - def _richcmp_(MatrixBase A, MatrixBase B, int op): - if (op == 2): - return deref(A.thisptr).eq(deref(B.thisptr)) - elif (op == 3): - return not deref(A.thisptr).eq(deref(B.thisptr)) - else: - return NotImplemented - - def __dealloc__(self): - del self.thisptr - - def _symbolic_(self, ring): - return ring(self._sage_()) - - # TODO: fix this - def __hash__(self): - return 0 - - -class MatrixError(Exception): - pass - - -class ShapeError(ValueError, MatrixError): - """Wrong matrix shape""" - pass - - -class NonSquareMatrixError(ShapeError): - pass - -cdef class DenseMatrixBase(MatrixBase): - """ - Represents a two-dimensional dense matrix. - - Examples - ======== - - Empty matrix: - - >>> DenseMatrix(3, 2) - - 2D Matrix: - - >>> DenseMatrix(3, 2, [1, 2, 3, 4, 5, 6]) - [1, 2] - [3, 4] - [5, 6] - - >>> DenseMatrix([[1, 2], [3, 4], [5, 6]]) - [1, 2] - [3, 4] - [5, 6] - - """ - - def __cinit__(self, row=None, col=None, v=None): - if row is None: - self.thisptr = new symengine.DenseMatrix(0, 0) - return - if v is None and col is not None: - self.thisptr = new symengine.DenseMatrix(row, col) - return - if col is None: - v = sympify(row) - row = 0 - cdef symengine.vec_basic v_ - cdef DenseMatrixBase A - cdef Basic e_ - #TODO: Add a constructor to DenseMatrix in C++ - if (isinstance(v, DenseMatrixBase)): - matrix_to_vec(v, v_) - if col is None: - row = v.nrows() - col = v.ncols() - self.thisptr = new symengine.DenseMatrix(row, col, v_) - return - for e in v: - f = sympify(e) - if isinstance(f, DenseMatrixBase): - matrix_to_vec(f, v_) - if col is None: - row = row + f.nrows() - continue - try: - for e_ in f: - v_.push_back(e_.thisptr) - if col is None: - row = row + 1 - except TypeError: - e_ = f - v_.push_back(e_.thisptr) - if col is None: - row = row + 1 - if (row == 0): - if (v_.size() != 0): - self.thisptr = new symengine.DenseMatrix(0, 0, v_) - raise ValueError("sizes don't match.") - else: - self.thisptr = new symengine.DenseMatrix(0, 0, v_) - elif col is not None and (row*col != v_.size()): - raise ValueError("Number of elements should equal rows*columns.") - else: - self.thisptr = new symengine.DenseMatrix(row, v_.size() / row, v_) - - def __repr__(self): - return self.__str__() - - def __str__(self): - return deref(self.thisptr).__str__().decode("utf-8") - - def _repr_latex_(self): - if repr_latex[0]: - return "${}$".format(latex(self)) - else: - return None - - def __add__(a, b): - a = _sympify(a, False) - b = _sympify(b, False) - if not isinstance(a, MatrixBase) or not isinstance(b, MatrixBase): - return NotImplemented - cdef MatrixBase a_ = a - cdef MatrixBase b_ = b - if (a_.shape == (0, 0)): - return b_ - if (b_.shape == (0, 0)): - return a_ - if (a_.shape != b_.shape): - raise ShapeError("Invalid shapes for matrix addition. Got %s %s" % (a_.shape, b_.shape)) - return a_.add_matrix(b_) - - def __radd__(MatrixBase self, a): - a = _sympify(a, False) - if not isinstance(a, MatrixBase): - return NotImplemented - cdef MatrixBase a_ = a - if (a_.shape == (0, 0)): - return self - if (self.shape == (0, 0)): - return a_ - if (self.shape != a_.shape): - raise ShapeError("Invalid shapes for matrix addition. Got %s %s" % (a_.shape, self.shape)) - return a_.add_matrix(self) - - def __mul__(a, b): - a = _sympify(a, False) - b = _sympify(b, False) - if isinstance(a, MatrixBase): - if isinstance(b, MatrixBase): - if (a.ncols() != b.nrows()): - raise ShapeError("Invalid shapes for matrix multiplication. Got %s %s" % (a.shape, b.shape)) - return a.mul_matrix(b) - elif isinstance(b, Basic): - return a.mul_scalar(b) - else: - return NotImplemented - elif isinstance(a, Basic): - return b.mul_scalar(a) - else: - return NotImplemented - - def __rmul__(Basic self, a): - a = _sympify(a, False) - if isinstance(a, MatrixBase): - if (a.ncols() != self.nrows()): - raise ShapeError("Invalid shapes for matrix multiplication. Got %s %s" % (a.shape, self.shape)) - return a.mul_matrix(self) - elif isinstance(a, Basic): - return self.mul_scalar(a) - else: - return NotImplemented - - def __matmul__(a, b): - a = _sympify(a, False) - b = _sympify(b, False) - if (a.ncols() != b.nrows()): - raise ShapeError("Invalid shapes for matrix multiplication. Got %s %s" % (a.shape, b.shape)) - return a.mul_matrix(b) - - def __rmatmul__(Basic self, a): - a = _sympify(a, False) - if (a.ncols() != self.nrows()): - raise ShapeError("Invalid shapes for matrix multiplication. Got %s %s" % (a.shape, self.shape)) - return a.mul_matrix(self) - - def __truediv__(a, b): - a = _sympify(a, False) - b = _sympify(b, False) - if isinstance(a, MatrixBase): - if isinstance(b, MatrixBase): - return a.mul_matrix(b.inv()) - elif isinstance(b, Basic): - return a.mul_scalar(1/b) - else: - return NotImplemented - else: - return NotImplemented - - def __rtruediv__(Basic self, a): - a = _sympify(a, False) - if isinstance(a, MatrixBase): - return a.mul_matrix(self.inv()) - else: - return NotImplemented - - def __sub__(a, b): - a = _sympify(a, False) - b = _sympify(b, False) - if not isinstance(a, MatrixBase) or not isinstance(b, MatrixBase): - return NotImplemented - cdef MatrixBase a_ = a - cdef MatrixBase b_ = b - if (a_.shape != b_.shape): - raise ShapeError("Invalid shapes for matrix subtraction. Got %s %s" % (a.shape, b.shape)) - return a_.add_matrix(-b_) - - def __rsub__(MatrixBase self, a): - a = _sympify(a, False) - if not isinstance(a, MatrixBase): - return NotImplemented - cdef MatrixBase a_ = a - if (a_.shape != self.shape): - raise ShapeError("Invalid shapes for matrix subtraction. Got %s %s" % (a.shape, self.shape)) - return a_.add_matrix(-self) - - def __neg__(self): - return self.mul_scalar(-1) - - def __abs__(self): - return self.applyfunc(abs) - - def __getitem__(self, item): - if isinstance(item, slice): - if (self.ncols() == 0 or self.nrows() == 0): - return [] - return [self.get(i // self.ncols(), i % self.ncols()) for i in range(*item.indices(len(self)))] - elif isinstance(item, int): - return self.get(item // self.ncols(), item % self.ncols()) - elif isinstance(item, tuple) and len(item) == 2: - if is_sequence(item[0]) or is_sequence(item[1]): - if isinstance(item[0], slice): - row_iter = range(*item[0].indices(self.rows)) - elif is_sequence(item[0]): - row_iter = item[0] - else: - row_iter = [item[0]] - - if isinstance(item[1], slice): - col_iter = range(*item[1].indices(self.cols)) - elif is_sequence(item[1]): - col_iter = item[1] - else: - col_iter = [item[1]] - - v = [] - for row in row_iter: - for col in col_iter: - v.append(self.get(row, col)) - return self.__class__(len(row_iter), len(col_iter), v) - - if isinstance(item[0], int) and isinstance(item[1], int): - return self.get(item[0], item[1]) - else: - s = [0, 0, 0, 0, 0, 0] - for i in (0, 1): - if isinstance(item[i], slice): - s[i], s[i+2], s[i+4] = item[i].indices(self.nrows() if i == 0 else self.ncols()) - else: - s[i], s[i+2], s[i+4] = item[i], item[i] + 1, 1 - if (s[0] < 0 or s[0] > self.rows or s[0] >= s[2] or s[2] < 0 or s[2] > self.rows): - raise IndexError - if (s[1] < 0 or s[1] > self.cols or s[1] >= s[3] or s[3] < 0 or s[3] > self.cols): - raise IndexError - return self._submatrix(*s) - elif is_sequence(item): - return [self.get(ind // self.ncols(), ind % self.ncols()) for ind in item] - else: - raise NotImplementedError - - def __setitem__(self, key, value): - cdef unsigned k, l - if isinstance(key, int): - self.set(key // self.ncols(), key % self.ncols(), value) - elif isinstance(key, slice): - k = 0 - for i in range(*key.indices(len(self))): - self.set(i // self.ncols(), i % self.ncols(), value[k]) - k = k + 1 - elif isinstance(key, tuple) and len(key) == 2: - if isinstance(key[0], slice): - row_iter = range(*key[0].indices(self.rows)) - elif is_sequence(key[0]): - row_iter = key[0] - else: - row_iter = [key[0]] - - if isinstance(key[1], slice): - col_iter = range(*key[1].indices(self.cols)) - elif is_sequence(key[1]): - col_iter = key[1] - else: - col_iter = [key[1]] - - for r, row in enumerate(row_iter): - for c, col in enumerate(col_iter): - if not is_sequence(value): - self.set(row, col, value) - continue - try: - self.set(row, col, value[r, c]) - continue - except TypeError: - pass - try: - self.set(row, col, value[r][c]) - continue - except TypeError: - pass - - if len(row_iter) == 1: - self.set(row, col, value[c]) - continue - - if len(col_iter) == 1: - self.set(row, col, value[r]) - continue - - elif is_sequence(key) and is_sequence(value): - for val, ind in zip(value, key): - self.set(ind // self.ncols(), ind % self.ncols(), val) - else: - raise NotImplementedError - - def row_join(self, rhs): - cdef DenseMatrixBase o = sympify(rhs) - if self.rows != o.rows: - raise ShapeError("`self` and `rhs` must have the same number of rows.") - cdef DenseMatrixBase d = self.__class__(self) - deref(symengine.static_cast_DenseMatrix(d.thisptr)).row_join(deref(symengine.static_cast_DenseMatrix(o.thisptr))) - return d - - def col_join(self, bott): - cdef DenseMatrixBase o = sympify(bott) - if self.cols != o.cols: - raise ShapeError("`self` and `rhs` must have the same number of columns.") - cdef DenseMatrixBase d = self.__class__(self) - deref(symengine.static_cast_DenseMatrix(d.thisptr)).col_join(deref(symengine.static_cast_DenseMatrix(o.thisptr))) - return d - - def row_insert(self, pos, bott): - cdef DenseMatrixBase o = sympify(bott) - if pos < 0: - pos = self.rows + pos - if pos < 0: - pos = 0 - elif pos > self.rows: - pos = self.rows - if self.cols != o.cols: - raise ShapeError("`self` and `other` must have the same number of columns.") - cdef DenseMatrixBase d = self.__class__(self) - deref(symengine.static_cast_DenseMatrix(d.thisptr)).row_insert(deref(symengine.static_cast_DenseMatrix(o.thisptr)), pos) - return d - - def col_insert(self, pos, bott): - cdef DenseMatrixBase o = sympify(bott) - if pos < 0: - pos = self.cols + pos - if pos < 0: - pos = 0 - elif pos > self.cols: - pos = self.cols - if self.rows != o.rows: - raise ShapeError("`self` and `other` must have the same number of rows.") - cdef DenseMatrixBase d = self.__class__(self) - deref(symengine.static_cast_DenseMatrix(d.thisptr)).col_insert(deref(symengine.static_cast_DenseMatrix(o.thisptr)), pos) - return d - - def dot(self, b): - cdef DenseMatrixBase o = sympify(b) - cdef DenseMatrixBase result = self.__class__(self.rows, self.cols) - symengine.dot(deref(symengine.static_cast_DenseMatrix(self.thisptr)), deref(symengine.static_cast_DenseMatrix(o.thisptr)), deref(symengine.static_cast_DenseMatrix(result.thisptr))) - if len(result) == 1: - return result[0, 0] - else: - return result - - def cross(self, b): - cdef DenseMatrixBase o = sympify(b) - if self.cols * self.rows != 3 or o.cols * o.rows != 3: - raise ShapeError("Dimensions incorrect for cross product: %s x %s" % - ((self.rows, self.cols), (b.rows, b.cols))) - cdef DenseMatrixBase result = self.__class__(self.rows, self.cols) - symengine.cross(deref(symengine.static_cast_DenseMatrix(self.thisptr)), deref(symengine.static_cast_DenseMatrix(o.thisptr)), deref(symengine.static_cast_DenseMatrix(result.thisptr))) - return result - - @property - def rows(self): - return self.nrows() - - @property - def cols(self): - return self.ncols() - - @property - def is_square(self): - return deref(self.thisptr).is_square() - - def nrows(self): - return deref(self.thisptr).nrows() - - def ncols(self): - return deref(self.thisptr).ncols() - - def __len__(self): - return self.nrows() * self.ncols() - - property shape: - def __get__(self): - return (self.nrows(), self.ncols()) - - property size: - def __get__(self): - return self.nrows()*self.ncols() - - def ravel(self, order='C'): - if order == 'C': - return [self._get(i, j) for i in range(self.nrows()) - for j in range(self.ncols())] - elif order == 'F': - return [self._get(i, j) for j in range(self.ncols()) - for i in range(self.nrows())] - else: - raise NotImplementedError("Unknown order '%s'" % order) - - def reshape(self, rows, cols): - if len(self) != rows*cols: - raise ValueError("Invalid reshape parameters %d %d" % (rows, cols)) - cdef DenseMatrixBase r = self.__class__(self) - deref(symengine.static_cast_DenseMatrix(r.thisptr)).resize(rows, cols) - return r - - def _get_index(self, i, j): - nr = self.nrows() - nc = self.ncols() - if i < 0: - i += nr - if j < 0: - j += nc - if i < 0 or i >= nr: - raise IndexError("Row index out of bounds: %d" % i) - if j < 0 or j >= nc: - raise IndexError("Column index out of bounds: %d" % j) - return i, j - - def get(self, i, j): - i, j = self._get_index(i, j) - return self._get(i, j) - - def _get(self, i, j): - # No error checking is done - return c2py(deref(self.thisptr).get(i, j)) - - def col(self, j): - return self[:, j] - - def row(self, i): - return self[i, :] - - def set(self, i, j, e): - i, j = self._get_index(i, j) - return self._set(i, j, e) - - def _set(self, i, j, e): - # No error checking is done - cdef Basic e_ = sympify(e) - if e_ is not None: - deref(self.thisptr).set(i, j, e_.thisptr) - - def det(self): - if self.nrows() != self.ncols(): - raise NonSquareMatrixError() - return c2py(deref(self.thisptr).det()) - - def inv(self, method='LU'): - cdef DenseMatrixBase result = self.__class__(self.nrows(), self.ncols()) - - if method.upper() == 'LU': - ## inv() method of DenseMatrixBase uses LU factorization - deref(self.thisptr).inv(deref(result.thisptr)) - elif method.upper() == 'FFLU': - symengine.inverse_FFLU(deref(symengine.static_cast_DenseMatrix(self.thisptr)), - deref(symengine.static_cast_DenseMatrix(result.thisptr))) - elif method.upper() == 'GJ': - symengine.inverse_GJ(deref(symengine.static_cast_DenseMatrix(self.thisptr)), - deref(symengine.static_cast_DenseMatrix(result.thisptr))) - else: - raise Exception("Unsupported method.") - return result - - def add_matrix(self, A): - cdef MatrixBase A_ = sympify(A) - if isinstance(A, ImmutableDenseMatrix): - cls = A.__class__ - else: - cls = self.__class__ - cdef DenseMatrixBase result = cls(self.nrows(), self.ncols()) - deref(self.thisptr).add_matrix(deref(A_.thisptr), deref(result.thisptr)) - return result - - def mul_matrix(self, A): - cdef MatrixBase A_ = sympify(A) - if isinstance(A, ImmutableDenseMatrix): - cls = A.__class__ - else: - cls = self.__class__ - cdef DenseMatrixBase result = cls(self.nrows(), A.ncols()) - deref(self.thisptr).mul_matrix(deref(A_.thisptr), deref(result.thisptr)) - return result - - def multiply_elementwise(self, A): - cdef MatrixBase A_ = sympify(A) - if isinstance(A, ImmutableDenseMatrix): - cls = A.__class__ - else: - cls = self.__class__ - cdef DenseMatrixBase result = cls(self.nrows(), self.ncols()) - deref(self.thisptr).elementwise_mul_matrix(deref(A_.thisptr), deref(result.thisptr)) - return result - - def add_scalar(self, k): - cdef Basic k_ = sympify(k) - cdef DenseMatrixBase result = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).add_scalar(k_.thisptr, deref(result.thisptr)) - return result - - def mul_scalar(self, k): - cdef Basic k_ = sympify(k) - cdef DenseMatrixBase result = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).mul_scalar(k_.thisptr, deref(result.thisptr)) - return result - - def transpose(self): - cdef DenseMatrixBase result = self.__class__(self.ncols(), self.nrows()) - deref(self.thisptr).transpose(deref(result.thisptr)) - return result - - def conjugate(self): - cdef DenseMatrixBase result = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).conjugate(deref(result.thisptr)) - return result - - def conjugate_transpose(self): - cdef DenseMatrixBase result = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).conjugate_transpose(deref(result.thisptr)) - return result - - @property - def H(self): - return self.conjugate_transpose() - - def trace(self): - return c2py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).trace()) - - @property - def is_zero_matrix(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_zero()) - - @property - def is_real_matrix(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_real()) - - @property - def is_diagonal(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_diagonal()) - - @property - def is_symmetric(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_symmetric()) - - @property - def is_hermitian(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_hermitian()) - - @property - def is_weakly_diagonally_dominant(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_weakly_diagonally_dominant()) - - @property - def is_strongly_diagonally_dominant(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_strictly_diagonally_dominant()) - - @property - def is_positive_definite(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_positive_definite()) - - @property - def is_negative_definite(self): - return tribool_py(deref(symengine.static_cast_DenseMatrix(self.thisptr)).is_negative_definite()) - - @property - def T(self): - return self.transpose() - - def applyfunc(self, f): - cdef DenseMatrixBase out = self.__class__(self) - cdef int nr = self.nrows() - cdef int nc = self.ncols() - cdef Basic e_; - for i in range(nr): - for j in range(nc): - e_ = sympify(f(self._get(i, j))) - if e_ is not None: - deref(out.thisptr).set(i, j, e_.thisptr) - return out - - def _applyfunc(self, f): - cdef int nr = self.nrows() - cdef int nc = self.ncols() - for i in range(nr): - for j in range(nc): - self._set(i, j, f(self._get(i, j))) - - def msubs(self, *args): - cdef _DictBasic D = get_dict(*args) - return self.applyfunc(lambda x: x.msubs(D)) - - def _diff(self, Basic x): - cdef DenseMatrixBase R = self.__class__(self.rows, self.cols) - symengine.diff(deref(self.thisptr), - x.thisptr, deref(R.thisptr)) - return R - - def diff(self, *args): - return _diff(self, *args) - - #TODO: implement this in C++ - def subs(self, *args): - cdef _DictBasic D = get_dict(*args) - return self.applyfunc(lambda x: x.subs(D)) - - def xreplace(self, *args): - cdef _DictBasic D = get_dict(*args) - return self.applyfunc(lambda x: x.xreplace(D)) - - replace = xreplace - - @property - def free_symbols(self): - cdef symengine.set_basic _set = symengine.free_symbols(deref(self.thisptr)) - return {c2py((elem)) for elem in _set} - - def _submatrix(self, unsigned r_i, unsigned c_i, unsigned r_j, unsigned c_j, unsigned r_s=1, unsigned c_s=1): - r_j, c_j = r_j - 1, c_j - 1 - cdef DenseMatrixBase result = self.__class__(((r_j - r_i) // r_s) + 1, ((c_j - c_i) // c_s) + 1) - deref(self.thisptr).submatrix(deref(result.thisptr), r_i, c_i, r_j, c_j, r_s, c_s) - return result - - def LU(self): - cdef DenseMatrixBase L = self.__class__(self.nrows(), self.ncols()) - cdef DenseMatrixBase U = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).LU(deref(L.thisptr), deref(U.thisptr)) - return L, U - - def LUdecomposition(self): - if self.rows != self.cols: - raise NotImplementedError("LU decomposition not implemented for non-square matrices yet.") - cdef DenseMatrixBase L = self.__class__(self.nrows(), self.ncols()) - cdef DenseMatrixBase U = self.__class__(self.nrows(), self.ncols()) - cdef vector[pair[int, int]] perm - symengine.pivoted_LU( - deref(symengine.static_cast_DenseMatrix(self.thisptr)), - deref(symengine.static_cast_DenseMatrix(L.thisptr)), - deref(symengine.static_cast_DenseMatrix(U.thisptr)), - perm) - return L, U, perm - - def LDL(self): - cdef DenseMatrixBase L = self.__class__(self.nrows(), self.ncols()) - cdef DenseMatrixBase D = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).LDL(deref(L.thisptr), deref(D.thisptr)) - return L, D - - def solve(self, b, method='LU'): - cdef DenseMatrixBase b_ = sympify(b) - cdef DenseMatrixBase x = self.__class__(b_.nrows(), b_.ncols()) - - if method.upper() == 'LU': - ## solve() method of DenseMatrixBase uses LU factorization - symengine.pivoted_LU_solve(deref(symengine.static_cast_DenseMatrix(self.thisptr)), - deref(symengine.static_cast_DenseMatrix(b_.thisptr)), - deref(symengine.static_cast_DenseMatrix(x.thisptr))) - elif method.upper() == 'FFLU': - symengine.FFLU_solve(deref(symengine.static_cast_DenseMatrix(self.thisptr)), - deref(symengine.static_cast_DenseMatrix(b_.thisptr)), - deref(symengine.static_cast_DenseMatrix(x.thisptr))) - elif method.upper() == 'LDL': - symengine.LDL_solve(deref(symengine.static_cast_DenseMatrix(self.thisptr)), - deref(symengine.static_cast_DenseMatrix(b_.thisptr)), - deref(symengine.static_cast_DenseMatrix(x.thisptr))) - elif method.upper() == 'FFGJ': - symengine.FFGJ_solve(deref(symengine.static_cast_DenseMatrix(self.thisptr)), - deref(symengine.static_cast_DenseMatrix(b_.thisptr)), - deref(symengine.static_cast_DenseMatrix(x.thisptr))) - else: - raise Exception("Unsupported method.") - - return x - - def LUsolve(self, b): - cdef DenseMatrixBase b_ = sympify(b) - cdef DenseMatrixBase x = self.__class__(b.nrows(), b.ncols()) - symengine.pivoted_LU_solve(deref(symengine.static_cast_DenseMatrix(self.thisptr)), - deref(symengine.static_cast_DenseMatrix(b_.thisptr)), - deref(symengine.static_cast_DenseMatrix(x.thisptr))) - return x - - def FFLU(self): - cdef DenseMatrixBase L = self.__class__(self.nrows(), self.ncols()) - cdef DenseMatrixBase U = self.__class__(self.nrows(), self.ncols(), [0]*self.nrows()*self.ncols()) - deref(self.thisptr).FFLU(deref(L.thisptr)) - - for i in range(self.nrows()): - for j in range(i + 1, self.ncols()): - U.set(i, j, L.get(i, j)) - L.set(i, j, 0) - U.set(i, i, L.get(i, i)) - - return L, U - - def FFLDU(self): - cdef DenseMatrixBase L = self.__class__(self.nrows(), self.ncols()) - cdef DenseMatrixBase D = self.__class__(self.nrows(), self.ncols()) - cdef DenseMatrixBase U = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).FFLDU(deref(L.thisptr), deref(D.thisptr), deref(U.thisptr)) - return L, D, U - - def QR(self): - cdef DenseMatrixBase Q = self.__class__(self.nrows(), self.ncols()) - cdef DenseMatrixBase R = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).QR(deref(Q.thisptr), deref(R.thisptr)) - return Q, R - - def cholesky(self): - cdef DenseMatrixBase L = self.__class__(self.nrows(), self.ncols()) - deref(self.thisptr).cholesky(deref(L.thisptr)) - return L - - def jacobian(self, x): - cdef DenseMatrixBase x_ = sympify(x) - cdef DenseMatrixBase R = self.__class__(self.nrows(), x.nrows()) - symengine.jacobian(deref(self.thisptr), - deref(x_.thisptr), - deref(R.thisptr)) - return R - - def _sympy_(self): - s = [] - cdef symengine.DenseMatrix A = deref(symengine.static_cast_DenseMatrix(self.thisptr)) - for i in range(A.nrows()): - l = [] - for j in range(A.ncols()): - l.append(c2py(A.get(i, j))._sympy_()) - s.append(l) - import sympy - return sympy.ImmutableMatrix(s) - - def _sage_(self): - s = [] - cdef symengine.DenseMatrix A = deref(symengine.static_cast_DenseMatrix(self.thisptr)) - for i in range(A.nrows()): - l = [] - for j in range(A.ncols()): - l.append(c2py(A.get(i, j))._sage_()) - s.append(l) - import sage.all as sage - return sage.Matrix(s, immutable=True) - - def dump_real(self, double[::1] out): - cdef size_t ri, ci, nr, nc - if out.size < self.size: - raise ValueError("out parameter too short") - nr = self.nrows() - nc = self.ncols() - for ri in range(nr): - for ci in range(nc): - out[ri*nc + ci] = symengine.eval_double(deref( - (deref(self.thisptr).get(ri, ci)))) - - def dump_complex(self, double complex[::1] out): - cdef size_t ri, ci, nr, nc - if out.size < self.size: - raise ValueError("out parameter too short") - nr = self.nrows() - nc = self.ncols() - for ri in range(nr): - for ci in range(nc): - out[ri*nc + ci] = symengine.eval_complex_double(deref( - (deref(self.thisptr).get(ri, ci)))) - - def __iter__(self): - return DenseMatrixBaseIter(self) - - def as_mutable(self): - return MutableDenseMatrix(self) - - def as_immutable(self): - return ImmutableDenseMatrix(self) - - def tolist(self): - return [[self[rowi, coli] for coli in range(self.ncols())] - for rowi in range(self.nrows())] - - def __array__(self): - return np.array(self.tolist()) - - def _mat(self): - return self - - def atoms(self, *types): - if types: - s = set() - if (isinstance(self, types)): - s.add(self) - for arg in self: - s.update(arg.atoms(*types)) - return s - else: - return self.free_symbols - - def simplify(self, *args, **kwargs): - return self._applyfunc(lambda x : x.simplify(*args, **kwargs)) - - def expand(self, *args, **kwargs): - return self.applyfunc(lambda x : x.expand(*args, **kwargs)) - - -class DenseMatrixBaseIter(object): - - def __init__(self, d): - self.curr = -1 - self.d = d - - def __iter__(self): - return self - - def __next__(self): - self.curr = self.curr + 1 - if (self.curr < self.d.rows * self.d.cols): - return self.d._get(self.curr // self.d.cols, self.curr % self.d.cols) - else: - raise StopIteration - - next = __next__ - -cdef class MutableDenseMatrix(DenseMatrixBase): - - def col_swap(self, i, j): - symengine.column_exchange_dense(deref(symengine.static_cast_DenseMatrix(self.thisptr)), i, j) - - def fill(self, value): - for i in range(self.rows): - for j in range(self.cols): - self[i, j] = value - - def row_swap(self, i, j): - symengine.row_exchange_dense(deref(symengine.static_cast_DenseMatrix(self.thisptr)), i, j) - - def rowmul(self, i, c, *args): - cdef Basic _c = sympify(c) - symengine.row_mul_scalar_dense(deref(symengine.static_cast_DenseMatrix(self.thisptr)), i, _c.thisptr) - return self - - def rowadd(self, i, j, c, *args): - cdef Basic _c = sympify(c) - symengine.row_add_row_dense(deref(symengine.static_cast_DenseMatrix(self.thisptr)), i, j, _c.thisptr) - return self - - def row_del(self, i): - if i < -self.rows or i >= self.rows: - raise IndexError("Index out of range: 'i = %s', valid -%s <= i" - " < %s" % (i, self.rows, self.rows)) - if i < 0: - i += self.rows - deref(symengine.static_cast_DenseMatrix(self.thisptr)).row_del(i) - return self - - def col_del(self, i): - if i < -self.cols or i >= self.cols: - raise IndexError("Index out of range: 'i=%s', valid -%s <= i < %s" - % (i, self.cols, self.cols)) - if i < 0: - i += self.cols - deref(symengine.static_cast_DenseMatrix(self.thisptr)).col_del(i) - return self - -Matrix = DenseMatrix = MutableDenseMatrix - -cdef class ImmutableDenseMatrix(DenseMatrixBase): - - def __setitem__(self, key, value): - raise TypeError("Cannot set values of {}".format(self.__class__)) - - def _applyfunc(self, f): - res = DenseMatrix(self) - res._applyfunc(f) - return ImmutableDenseMatrix(res) - - -ImmutableMatrix = ImmutableDenseMatrix - - -cdef matrix_to_vec(DenseMatrixBase d, symengine.vec_basic& v): - cdef Basic e_ - for i in range(d.nrows()): - for j in range(d.ncols()): - e_ = d._get(i, j) - v.push_back(e_.thisptr) - - -def eye(n): - cdef DenseMatrixBase d = DenseMatrix(n, n) - symengine.eye(deref(symengine.static_cast_DenseMatrix(d.thisptr)), 0) - return d - - -cdef symengine.vec_basic iter_to_vec_basic(iter): - cdef Basic B - cdef symengine.vec_basic V - for b in iter: - B = sympify(b) - V.push_back(B.thisptr) - return V - - -def diag(*values): - cdef DenseMatrixBase d = DenseMatrix(len(values), len(values)) - cdef symengine.vec_basic V = iter_to_vec_basic(values) - symengine.diag(deref(symengine.static_cast_DenseMatrix(d.thisptr)), V, 0) - return d - - -def ones(r, c = None): - if c is None: - c = r - cdef DenseMatrixBase d = DenseMatrix(r, c) - symengine.ones(deref(symengine.static_cast_DenseMatrix(d.thisptr))) - return d - - -def zeros(r, c = None): - if c is None: - c = r - cdef DenseMatrixBase d = DenseMatrix(r, c) - symengine.zeros(deref(symengine.static_cast_DenseMatrix(d.thisptr))) - return d - - -cdef class Sieve: - @staticmethod - def generate_primes(n): - cdef symengine.vector[unsigned] primes - symengine.sieve_generate_primes(primes, n) - s = [] - for i in range(primes.size()): - s.append(primes[i]) - return s - - -cdef class Sieve_iterator: - cdef symengine.sieve_iterator *thisptr - cdef unsigned limit - def __cinit__(self): - self.thisptr = new symengine.sieve_iterator() - self.limit = 0 - - def __cinit__(self, n): - self.thisptr = new symengine.sieve_iterator(n) - self.limit = n - - def __iter__(self): - return self - - def __next__(self): - n = deref(self.thisptr).next_prime() - if self.limit > 0 and n > self.limit: - raise StopIteration - else: - return n - - -def module_cleanup(): - global I, E, pi, oo, minus_oo, zoo, nan, true, false, golden_ratio, \ - catalan, eulergamma, sympy_module, sage_module, half, one, \ - minus_one, zero - funcs.clear() - del I, E, pi, oo, minus_oo, zoo, nan, true, false, golden_ratio, \ - catalan, eulergamma, sympy_module, sage_module, half, one, \ - minus_one, zero - -import atexit -atexit.register(module_cleanup) - - -def diff(expr, *args): - if isinstance(expr, MatrixBase): - # Don't sympify matrices so that mutable matrices - # return mutable matrices - return _diff(expr, *args) - return _diff(sympify(expr), *args) - - -def _diff(expr, *args): - cdef Basic prev - cdef Basic b - cdef size_t i - cdef size_t length = len(args) - - if not length: - return expr - - cdef size_t l = 0 - cdef Basic cur_arg, next_arg - cur_arg = sympify(args[l]) - - while l < length: - if isinstance(cur_arg, Integer): - raise ValueError("Unexpected integer argument") - - if l + 1 == length: - # No next argument, differentiate with no integer argument - return expr._diff(cur_arg) - - next_arg = sympify(args[l + 1]) - # Check if the next arg was derivative order - if isinstance(next_arg, Integer): - i = int(next_arg) - for _ in range(i): - expr = expr._diff(cur_arg) - l += 2 - if l == length: - return expr - cur_arg = sympify(args[l]) - else: - expr = expr._diff(cur_arg) - l += 1 - cur_arg = next_arg - - -def expand(x, deep=True): - return sympify(x).expand(deep) - -expand_mul = expand - -def function_symbol(name, *args): - cdef symengine.vec_basic v - cdef Basic e_ - for e in args: - e_ = sympify(e) - if e_ is not None: - v.push_back(e_.thisptr) - return c2py(symengine.function_symbol(name.encode("utf-8"), v)) - -def sqrt(x): - cdef Basic X = sympify(x) - return c2py(symengine.sqrt(X.thisptr)) - -def exp(x): - cdef Basic X = sympify(x) - return c2py(symengine.exp(X.thisptr)) - -def perfect_power(n): - cdef Basic _n = sympify(n) - require(_n, Integer) - return symengine.perfect_power(deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - -def is_square(n): - cdef Basic _n = sympify(n) - require(_n, Integer) - return symengine.perfect_square(deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - -def integer_nthroot(a, n): - cdef Basic _a = sympify(a) - require(_a, Integer) - cdef RCP[const symengine.Integer] _r - cdef int ret_val = symengine.i_nth_root(symengine.outArg_Integer(_r), deref(symengine.rcp_static_cast_Integer(_a.thisptr)), n) - return (c2py(_r), ret_val == 1) - -def _max(*args): - cdef symengine.vec_basic v - cdef Basic e_ - for e in args: - e_ = sympify(e) - v.push_back(e_.thisptr) - return c2py(symengine.max(v)) - -def _min(*args): - cdef symengine.vec_basic v - cdef Basic e_ - for e in args: - e_ = sympify(e) - v.push_back(e_.thisptr) - return c2py(symengine.min(v)) - -def gamma(x): - cdef Basic X = sympify(x) - return c2py(symengine.gamma(X.thisptr)) - -def eq(lhs, rhs = None): - cdef Basic X = sympify(lhs) - if rhs is None: - return c2py((symengine.Eq(X.thisptr))) - cdef Basic Y = sympify(rhs) - return c2py((symengine.Eq(X.thisptr, Y.thisptr))) - -def ne(lhs, rhs): - cdef Basic X = sympify(lhs) - cdef Basic Y = sympify(rhs) - return c2py((symengine.Ne(X.thisptr, Y.thisptr))) - -def ge(lhs, rhs): - cdef Basic X = sympify(lhs) - cdef Basic Y = sympify(rhs) - return c2py((symengine.Ge(X.thisptr, Y.thisptr))) - -Ge = GreaterThan = ge - -def gt(lhs, rhs): - cdef Basic X = sympify(lhs) - cdef Basic Y = sympify(rhs) - return c2py((symengine.Gt(X.thisptr, Y.thisptr))) - -Gt = StrictGreaterThan = gt - -def le(lhs, rhs): - cdef Basic X = sympify(lhs) - cdef Basic Y = sympify(rhs) - return c2py((symengine.Le(X.thisptr, Y.thisptr))) - -def lt(lhs, rhs): - cdef Basic X = sympify(lhs) - cdef Basic Y = sympify(rhs) - return c2py((symengine.Lt(X.thisptr, Y.thisptr))) - -def digamma(x): - cdef Basic X = sympify(x) - return c2py(symengine.digamma(X.thisptr)) - -def trigamma(x): - cdef Basic X = sympify(x) - return c2py(symengine.trigamma(X.thisptr)) - -def logical_and(*args): - cdef symengine.set_boolean s - cdef Boolean e_ - for e in args: - e_ = sympify(e) - s.insert(symengine.rcp_static_cast_Boolean(e_.thisptr)) - return c2py((symengine.logical_and(s))) - -def logical_or(*args): - cdef symengine.set_boolean s - cdef Boolean e_ - for e in args: - e_ = sympify(e) - s.insert(symengine.rcp_static_cast_Boolean(e_.thisptr)) - return c2py((symengine.logical_or(s))) - -def Nor(*args): - cdef symengine.set_boolean s - cdef Boolean e_ - for e in args: - e_ = sympify(e) - s.insert(symengine.rcp_static_cast_Boolean(e_.thisptr)) - return c2py((symengine.logical_nor(s))) - -def Nand(*args): - cdef symengine.set_boolean s - cdef Boolean e_ - for e in args: - e_ = sympify(e) - s.insert(symengine.rcp_static_cast_Boolean(e_.thisptr)) - return c2py((symengine.logical_nand(s))) - -def logical_not(x): - cdef Basic x_ = sympify(x) - require(x_, Boolean) - cdef RCP[const symengine.Boolean] _x = symengine.rcp_static_cast_Boolean(x_.thisptr) - return c2py((symengine.logical_not(_x))) - -def logical_xor(*args): - cdef symengine.vec_boolean v - cdef Boolean e_ - for e in args: - e_ = sympify(e) - v.push_back(symengine.rcp_static_cast_Boolean(e_.thisptr)) - return c2py((symengine.logical_xor(v))) - -def Xnor(*args): - cdef symengine.vec_boolean v - cdef Boolean e_ - for e in args: - e_ = sympify(e) - v.push_back(symengine.rcp_static_cast_Boolean(e_.thisptr)) - return c2py((symengine.logical_xnor(v))) - -def evalf(x, unsigned long bits=53, real=None): - cdef Basic X = sympify(x) - cdef symengine.EvalfDomain d - if real is None: - d = symengine.EvalfSymbolic - elif real: - d = symengine.EvalfReal - else: - d = symengine.EvalfComplex - return c2py((symengine.evalf(deref(X.thisptr), bits, d))) - -def eval_double(x): - warnings.warn("eval_double is deprecated. Use evalf(..., real=True)", DeprecationWarning) - return evalf(x, 53, real=True) - -def eval_complex_double(x): - warnings.warn("eval_complex_double is deprecated. Use evalf(..., real=False)", DeprecationWarning) - return evalf(x, 53, real=False) - -have_mpfr = False -have_mpc = False -have_piranha = False -have_flint = False -have_llvm = False -have_llvm_long_double = False - -IF HAVE_SYMENGINE_MPFR: - have_mpfr = True - def eval_mpfr(x, unsigned long prec): - warnings.warn("eval_mpfr is deprecated. Use evalf(..., real=True)", DeprecationWarning) - return evalf(x, prec, real=True) - -IF HAVE_SYMENGINE_MPC: - have_mpc = True - def eval_mpc(x, unsigned long prec): - warnings.warn("eval_mpc is deprecated. Use evalf(..., real=False)", DeprecationWarning) - return evalf(x, prec, real=False) - -IF HAVE_SYMENGINE_PIRANHA: - have_piranha = True - -IF HAVE_SYMENGINE_FLINT: - have_flint = True - -IF HAVE_SYMENGINE_LLVM: - have_llvm = True - -IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE: - have_llvm_long_double = True - -def require(obj, t): - if not isinstance(obj, t): - raise TypeError("{} required. {} is of type {}".format(t, obj, type(obj))) - -def eval(x, long prec): - warnings.warn("eval is deprecated. Use evalf(..., real=False)", DeprecationWarning) - return evalf(x, prec, real=False) - -def eval_real(x, long prec): - warnings.warn("eval_real is deprecated. Use evalf(..., real=True)", DeprecationWarning) - return evalf(x, prec, real=True) - -def probab_prime_p(n, reps = 25): - cdef Basic _n = sympify(n) - require(_n, Integer) - return symengine.probab_prime_p(deref(symengine.rcp_static_cast_Integer(_n.thisptr)), reps) >= 1 - -isprime = probab_prime_p - -def nextprime(n): - cdef Basic _n = sympify(n) - require(_n, Integer) - return c2py((symengine.nextprime(deref(symengine.rcp_static_cast_Integer(_n.thisptr))))) - -def gcd(a, b): - cdef Basic _a = sympify(a) - cdef Basic _b = sympify(b) - require(_a, Integer) - require(_b, Integer) - return c2py((symengine.gcd(deref(symengine.rcp_static_cast_Integer(_a.thisptr)), - deref(symengine.rcp_static_cast_Integer(_b.thisptr))))) - -def lcm(a, b): - cdef Basic _a = sympify(a) - cdef Basic _b = sympify(b) - require(_a, Integer) - require(_b, Integer) - return c2py((symengine.lcm(deref(symengine.rcp_static_cast_Integer(_a.thisptr)), - deref(symengine.rcp_static_cast_Integer(_b.thisptr))))) - -def gcd_ext(a, b): - cdef Basic _a = sympify(a) - cdef Basic _b = sympify(b) - require(_a, Integer) - require(_b, Integer) - cdef RCP[const symengine.Integer] g, s, t - symengine.gcd_ext(symengine.outArg_Integer(g), symengine.outArg_Integer(s), symengine.outArg_Integer(t), - deref(symengine.rcp_static_cast_Integer(_a.thisptr)), deref(symengine.rcp_static_cast_Integer(_b.thisptr))) - return (c2py(s), c2py(t), c2py(g)) - -igcdex = gcd_ext - -def mod(a, b): - if b == 0: - raise ZeroDivisionError - cdef Basic _a = sympify(a) - cdef Basic _b = sympify(b) - require(_a, Integer) - require(_b, Integer) - return c2py((symengine.mod(deref(symengine.rcp_static_cast_Integer(_a.thisptr)), - deref(symengine.rcp_static_cast_Integer(_b.thisptr))))) - -def quotient(a, b): - if b == 0: - raise ZeroDivisionError - cdef Basic _a = sympify(a) - cdef Basic _b = sympify(b) - require(_a, Integer) - require(_b, Integer) - return c2py((symengine.quotient(deref(symengine.rcp_static_cast_Integer(_a.thisptr)), - deref(symengine.rcp_static_cast_Integer(_b.thisptr))))) - -def quotient_mod(a, b): - if b == 0: - raise ZeroDivisionError - cdef RCP[const symengine.Integer] q, r - cdef Basic _a = sympify(a) - cdef Basic _b = sympify(b) - require(_a, Integer) - require(_b, Integer) - symengine.quotient_mod(symengine.outArg_Integer(q), symengine.outArg_Integer(r), - deref(symengine.rcp_static_cast_Integer(_a.thisptr)), deref(symengine.rcp_static_cast_Integer(_b.thisptr))) - return (c2py(q), c2py(r)) - -def mod_inverse(a, b): - cdef RCP[const symengine.Integer] inv - cdef Basic _a = sympify(a) - cdef Basic _b = sympify(b) - require(_a, Integer) - require(_b, Integer) - cdef int ret_val = symengine.mod_inverse(symengine.outArg_Integer(inv), - deref(symengine.rcp_static_cast_Integer(_a.thisptr)), deref(symengine.rcp_static_cast_Integer(_b.thisptr))) - if ret_val == 0: - return None - return c2py(inv) - -def crt(rem, mod): - cdef symengine.vec_integer _rem, _mod - cdef Basic _a - cdef cppbool ret_val - for i in range(len(rem)): - _a = sympify(rem[i]) - require(_a, Integer) - _rem.push_back(symengine.rcp_static_cast_Integer(_a.thisptr)) - _a = sympify(mod[i]) - require(_a, Integer) - _mod.push_back(symengine.rcp_static_cast_Integer(_a.thisptr)) - - cdef RCP[const symengine.Integer] c - ret_val = symengine.crt(symengine.outArg_Integer(c), _rem, _mod) - if not ret_val: - return None - return c2py(c) - -def fibonacci(n): - if n < 0 : - raise NotImplementedError - return c2py((symengine.fibonacci(n))) - -def fibonacci2(n): - if n < 0 : - raise NotImplementedError - cdef RCP[const symengine.Integer] f1, f2 - symengine.fibonacci2(symengine.outArg_Integer(f1), symengine.outArg_Integer(f2), n) - return [c2py(f1), c2py(f2)] - -def lucas(n): - if n < 0 : - raise NotImplementedError - return c2py((symengine.lucas(n))) - -def lucas2(n): - if n < 0 : - raise NotImplementedError - cdef RCP[const symengine.Integer] f1, f2 - symengine.lucas2(symengine.outArg_Integer(f1), symengine.outArg_Integer(f2), n) - return [c2py(f1), c2py(f2)] - -def binomial(n, k): - if k < 0: - raise ArithmeticError - cdef Basic _n = sympify(n) - require(_n, Integer) - return c2py(symengine.binomial(deref(symengine.rcp_static_cast_Integer(_n.thisptr)), k)) - -def factorial(n): - if n < 0: - raise ArithmeticError - return c2py((symengine.factorial(n))) - -def divides(a, b): - cdef Basic _a = sympify(a) - cdef Basic _b = sympify(b) - require(_a, Integer) - require(_b, Integer) - return symengine.divides(deref(symengine.rcp_static_cast_Integer(_a.thisptr)), - deref(symengine.rcp_static_cast_Integer(_b.thisptr))) - -def factor(n, B1 = 1.0): - cdef Basic _n = sympify(n) - require(_n, Integer) - cdef RCP[const symengine.Integer] f - cdef int ret_val = symengine.factor(symengine.outArg_Integer(f), - deref(symengine.rcp_static_cast_Integer(_n.thisptr)), B1) - if (ret_val == 1): - return c2py(f) - else: - return None - -def factor_lehman_method(n): - cdef Basic _n = sympify(n) - require(_n, Integer) - cdef RCP[const symengine.Integer] f - cdef int ret_val = symengine.factor_lehman_method(symengine.outArg_Integer(f), - deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - if (ret_val == 1): - return c2py(f) - else: - return None - -def factor_pollard_pm1_method(n, B = 10, retries = 5): - cdef Basic _n = sympify(n) - require(_n, Integer) - cdef RCP[const symengine.Integer] f - cdef int ret_val = symengine.factor_pollard_pm1_method(symengine.outArg_Integer(f), - deref(symengine.rcp_static_cast_Integer(_n.thisptr)), B, retries) - if (ret_val == 1): - return c2py(f) - else: - return None - -def factor_pollard_rho_method(n, retries = 5): - cdef Basic _n = sympify(n) - require(_n, Integer) - cdef RCP[const symengine.Integer] f - cdef int ret_val = symengine.factor_pollard_rho_method(symengine.outArg_Integer(f), - deref(symengine.rcp_static_cast_Integer(_n.thisptr)), retries) - if (ret_val == 1): - return c2py(f) - else: - return None - -def prime_factors(n): - cdef symengine.vec_integer factors - cdef Basic _n = sympify(n) - require(_n, Integer) - symengine.prime_factors(factors, deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - s = [] - for i in range(factors.size()): - s.append(c2py((factors[i]))) - return s - -def prime_factor_multiplicities(n): - cdef symengine.vec_integer factors - cdef Basic _n = sympify(n) - require(_n, Integer) - symengine.prime_factors(factors, deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - cdef Basic r - dict = {} - for i in range(factors.size()): - r = c2py((factors[i])) - if (r not in dict): - dict[r] = 1 - else: - dict[r] += 1 - return dict - -def bernoulli(n): - if n < 0: - raise ArithmeticError - return c2py((symengine.bernoulli(n))) - -def primitive_root(n): - cdef RCP[const symengine.Integer] g - cdef Basic _n = sympify(n) - require(_n, Integer) - cdef cppbool ret_val = symengine.primitive_root(symengine.outArg_Integer(g), - deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - if ret_val == 0: - return None - return c2py(g) - -def primitive_root_list(n): - cdef symengine.vec_integer root_list - cdef Basic _n = sympify(n) - require(_n, Integer) - symengine.primitive_root_list(root_list, - deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - s = [] - for i in range(root_list.size()): - s.append(c2py((root_list[i]))) - return s - -def totient(n): - cdef Basic _n = sympify(n) - require(_n, Integer) - cdef RCP[const symengine.Integer] m = symengine.rcp_static_cast_Integer(_n.thisptr) - return c2py(symengine.totient(m)) - -def carmichael(n): - cdef Basic _n = sympify(n) - require(_n, Integer) - cdef RCP[const symengine.Integer] m = symengine.rcp_static_cast_Integer(_n.thisptr) - return c2py(symengine.carmichael(m)) - -def multiplicative_order(a, n): - cdef Basic _n = sympify(n) - cdef Basic _a = sympify(a) - require(_n, Integer) - require(_a, Integer) - cdef RCP[const symengine.Integer] n1 = symengine.rcp_static_cast_Integer(_n.thisptr) - cdef RCP[const symengine.Integer] a1 = symengine.rcp_static_cast_Integer(_a.thisptr) - cdef RCP[const symengine.Integer] o - cdef cppbool c = symengine.multiplicative_order(symengine.outArg_Integer(o), - a1, n1) - if not c: - return None - return c2py(o) - -def legendre(a, n): - cdef Basic _n = sympify(n) - cdef Basic _a = sympify(a) - require(_n, Integer) - require(_a, Integer) - return symengine.legendre(deref(symengine.rcp_static_cast_Integer(_a.thisptr)), - deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - -def jacobi(a, n): - cdef Basic _n = sympify(n) - cdef Basic _a = sympify(a) - require(_n, Integer) - require(_a, Integer) - return symengine.jacobi(deref(symengine.rcp_static_cast_Integer(_a.thisptr)), - deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - -def kronecker(a, n): - cdef Basic _n = sympify(n) - cdef Basic _a = sympify(a) - require(_n, Integer) - require(_a, Integer) - return symengine.kronecker(deref(symengine.rcp_static_cast_Integer(_a.thisptr)), - deref(symengine.rcp_static_cast_Integer(_n.thisptr))) - -def nthroot_mod(a, n, m): - cdef RCP[const symengine.Integer] root - cdef Basic _n = sympify(n) - cdef Basic _a = sympify(a) - cdef Basic _m = sympify(m) - require(_n, Integer) - require(_a, Integer) - require(_m, Integer) - cdef RCP[const symengine.Integer] n1 = symengine.rcp_static_cast_Integer(_n.thisptr) - cdef RCP[const symengine.Integer] a1 = symengine.rcp_static_cast_Integer(_a.thisptr) - cdef RCP[const symengine.Integer] m1 = symengine.rcp_static_cast_Integer(_m.thisptr) - cdef cppbool ret_val = symengine.nthroot_mod(symengine.outArg_Integer(root), a1, n1, m1) - if not ret_val: - return None - return c2py(root) - -def nthroot_mod_list(a, n, m): - cdef symengine.vec_integer root_list - cdef Basic _n = sympify(n) - cdef Basic _a = sympify(a) - cdef Basic _m = sympify(m) - require(_n, Integer) - require(_a, Integer) - require(_m, Integer) - cdef RCP[const symengine.Integer] n1 = symengine.rcp_static_cast_Integer(_n.thisptr) - cdef RCP[const symengine.Integer] a1 = symengine.rcp_static_cast_Integer(_a.thisptr) - cdef RCP[const symengine.Integer] m1 = symengine.rcp_static_cast_Integer(_m.thisptr) - symengine.nthroot_mod_list(root_list, a1, n1, m1) - s = [] - for i in range(root_list.size()): - s.append(c2py((root_list[i]))) - return s - -def sqrt_mod(a, p, all_roots=False): - if all_roots: - return nthroot_mod_list(a, 2, p) - return nthroot_mod(a, 2, p) - -def powermod(a, b, m): - cdef Basic _a = sympify(a) - cdef Basic _m = sympify(m) - cdef Number _b = sympify(b) - require(_a, Integer) - require(_m, Integer) - cdef RCP[const symengine.Integer] a1 = symengine.rcp_static_cast_Integer(_a.thisptr) - cdef RCP[const symengine.Integer] m1 = symengine.rcp_static_cast_Integer(_m.thisptr) - cdef RCP[const symengine.Number] b1 = symengine.rcp_static_cast_Number(_b.thisptr) - cdef RCP[const symengine.Integer] root - cdef cppbool ret_val = symengine.powermod(symengine.outArg_Integer(root), a1, b1, m1) - if ret_val == 0: - return None - return c2py(root) - -def powermod_list(a, b, m): - cdef Basic _a = sympify(a) - cdef Basic _m = sympify(m) - cdef Number _b = sympify(b) - require(_a, Integer) - require(_m, Integer) - cdef RCP[const symengine.Integer] a1 = symengine.rcp_static_cast_Integer(_a.thisptr) - cdef RCP[const symengine.Integer] m1 = symengine.rcp_static_cast_Integer(_m.thisptr) - cdef RCP[const symengine.Number] b1 = symengine.rcp_static_cast_Number(_b.thisptr) - cdef symengine.vec_integer v - - symengine.powermod_list(v, a1, b1, m1) - s = [] - for i in range(v.size()): - s.append(c2py((v[i]))) - return s - -def has_symbol(obj, symbol=None): - cdef Basic b = _sympify(obj) - cdef Basic s = _sympify(symbol) - require(s, (Symbol, FunctionSymbol)) - if (not symbol): - return not b.free_symbols.empty() - else: - return symengine.has_symbol(deref(b.thisptr), deref(s.thisptr)) - - -cdef class _Lambdify(object): - def __init__(self, args, *exprs, cppbool real=True, order='C', cppbool cse=False, cppbool _load=False, dtype=None, **kwargs): - cdef: - Basic e_ - size_t ri, ci, nr, nc - symengine.MatrixBase *mtx - rcp_const_basic b_ - symengine.vec_basic args_, outs_ - vector[int] out_sizes - - if _load: - self.args_size, self.tot_out_size, self.out_shapes, self.real, \ - self.n_exprs, self.order, self.accum_out_sizes, self.numpy_dtype, \ - llvm_function = args - self._load(llvm_function) - return - - args = np.asanyarray(args) - self.args_size = args.size - exprs = tuple(np.asanyarray(expr) for expr in exprs) - self.out_shapes = [expr.shape for expr in exprs] - self.n_exprs = len(exprs) - self.real = real - self.order = order - self.numpy_dtype = dtype if dtype else (np.float64 if self.real else np.complex128) - if self.args_size == 0: - raise NotImplementedError("Support for zero arguments not yet supported") - self.tot_out_size = 0 - for idx, shape in enumerate(self.out_shapes): - out_sizes.push_back(reduce(mul, shape or (1,))) - self.tot_out_size += out_sizes[idx] - for i in range(self.n_exprs + 1): - self.accum_out_sizes.push_back(0) - for j in range(i): - self.accum_out_sizes[i] += out_sizes[j] - - for arg in np.ravel(args, order=self.order): - e_ = _sympify(arg) - args_.push_back(e_.thisptr) - - for curr_expr in exprs: - if curr_expr.ndim == 0: - e_ = _sympify(curr_expr.item()) - outs_.push_back(e_.thisptr) - else: - for e in np.ravel(curr_expr, order=self.order): - e_ = _sympify(e) - outs_.push_back(e_.thisptr) - self._init(args_, outs_, cse) - - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - raise ValueError("Not supported") - - cdef _load(self, const string &s): - raise ValueError("Not supported") - - cpdef eval_real(self, inp, out): - if inp.size != self.args_size: - raise ValueError("Size of inp incompatible with number of args.") - if out.size != self.tot_out_size: - raise ValueError("Size of out incompatible with number of exprs.") - self.unsafe_real(inp, out) - - cpdef eval_complex(self, inp, out): - if inp.size != self.args_size: - raise ValueError("Size of inp incompatible with number of args.") - if out.size != self.tot_out_size: - raise ValueError("Size of out incompatible with number of exprs.") - self.unsafe_complex(inp, out) - - cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): - raise ValueError("Not supported") - - def __call__(self, *args, out=None): - """ - Parameters - ---------- - inp: array_like - last dimension must be equal to number of arguments. - out: array_like or None (default) - Allows for low-overhead use (output argument, must be contiguous). - If ``None``: an output container will be allocated (NumPy ndarray). - If ``len(exprs) > 0`` output is found in the corresponding - order. - - Returns - ------- - If ``len(exprs) == 1``: ``numpy.ndarray``, otherwise a tuple of such. - - """ - cdef: - size_t idx, new_tot_out_size, nbroadcast = 1 - if self.order not in ('C', 'F'): - raise NotImplementedError("Only C & F order supported for now.") - - if len(args) == 1: - args = args[0] - - try: - inp = np.asanyarray(args, dtype=self.numpy_dtype) - except TypeError: - inp = np.fromiter(args, dtype=self.numpy_dtype) - - if inp.size < self.args_size or inp.size % self.args_size != 0: - raise ValueError("Broadcasting failed (input/arg size mismatch)") - nbroadcast = inp.size // self.args_size - - if inp.ndim > 1: - if self.args_size > 1: - if self.order == 'C': - if inp.shape[inp.ndim-1] != self.args_size: - raise ValueError(("C order implies last dim (%d) == len(args)" - " (%d)") % (inp.shape[inp.ndim-1], self.args_size)) - extra_dim = inp.shape[:inp.ndim-1] - elif self.order == 'F': - if inp.shape[0] != self.args_size: - raise ValueError("F order implies first dim (%d) == len(args) (%d)" - % (inp.shape[0], self.args_size)) - extra_dim = inp.shape[1:] - else: - extra_dim = inp.shape - else: - if nbroadcast > 1 and inp.ndim == 1: - extra_dim = (nbroadcast,) # special case - else: - extra_dim = () - extra_left = extra_dim if self.order == 'C' else () - extra_right = () if self.order == 'C' else extra_dim - new_out_shapes = [extra_left + out_shape + extra_right - for out_shape in self.out_shapes] - - new_tot_out_size = nbroadcast * self.tot_out_size - if out is None: - out = np.empty(new_tot_out_size, dtype=self.numpy_dtype, order=self.order) - else: - if out.size < new_tot_out_size: - raise ValueError("Incompatible size of output argument") - if out.ndim > 1: - if len(self.out_shapes) > 1: - raise ValueError("output array with ndim > 1 assumes one output") - out_shape, = self.out_shapes - if self.order == 'C': - if not out.flags['C_CONTIGUOUS']: - raise ValueError("Output argument needs to be C-contiguous") - if out.shape[-len(out_shape):] != tuple(out_shape): - raise ValueError("shape mismatch for output array") - elif self.order == 'F': - if not out.flags['F_CONTIGUOUS']: - raise ValueError("Output argument needs to be F-contiguous") - if out.shape[:len(out_shape)] != tuple(out_shape): - raise ValueError("shape mismatch for output array") - else: - if not out.flags['F_CONTIGUOUS']: # or C_CONTIGUOUS (ndim <= 1) - raise ValueError("Output array need to be contiguous") - if not out.flags['WRITEABLE']: - raise ValueError("Output argument needs to be writeable") - out = out.ravel(order=self.order) - - self.unsafe_eval(inp, out, nbroadcast) - - if self.order == 'C': - out = out.reshape((nbroadcast, self.tot_out_size), order='C') - result = [ - out[:, self.accum_out_sizes[idx]:self.accum_out_sizes[idx+1]].reshape( - new_out_shapes[idx], order='C') for idx in range(self.n_exprs) - ] - elif self.order == 'F': - out = out.reshape((self.tot_out_size, nbroadcast), order='F') - result = [ - out[self.accum_out_sizes[idx]:self.accum_out_sizes[idx+1], :].reshape( - new_out_shapes[idx], order='F') for idx in range(self.n_exprs) - ] - if self.n_exprs == 1: - return result[0] - else: - return result - - -cdef double _scipy_callback_lambda_real(int n, double *x, void *user_data) noexcept nogil: - cdef symengine.LambdaRealDoubleVisitor* lamb = user_data - cdef double result - deref(lamb).call(&result, x) - return result - -cdef void _ctypes_callback_lambda_real(double *output, const double *input, void *user_data) noexcept nogil: - cdef symengine.LambdaRealDoubleVisitor* lamb = user_data - deref(lamb).call(output, input) - -IF HAVE_SYMENGINE_LLVM: - cdef double _scipy_callback_llvm_real(int n, double *x, void *user_data) noexcept nogil: - cdef symengine.LLVMDoubleVisitor* lamb = user_data - cdef double result - deref(lamb).call(&result, x) - return result - - cdef void _ctypes_callback_llvm_real(double *output, const double *input, void *user_data) noexcept nogil: - cdef symengine.LLVMDoubleVisitor* lamb = user_data - deref(lamb).call(output, input) - - -def create_low_level_callable(lambdify, *args): - from scipy import LowLevelCallable - class LambdifyLowLevelCallable(LowLevelCallable): - def __init__(self, lambdify, *args): - self.lambdify = lambdify - def __new__(cls, value, *args, **kwargs): - return super(LambdifyLowLevelCallable, cls).__new__(cls, *args) - return LambdifyLowLevelCallable(lambdify, *args) - - -cdef class LambdaDouble(_Lambdify): - def __cinit__(self, args, *exprs, cppbool real=True, order='C', cppbool cse=False, cppbool _load=False, dtype=None): - # reject additional arguments - pass - - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_visitor.reset(new symengine.LambdaRealDoubleVisitor()) - deref(self.lambda_visitor).init(args_, outs_, cse) - - cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=0, int out_offset=0): - deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) - - cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): - cdef double[::1] c_inp, c_out - cdef unsigned idx - c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) - c_out = out - for idx in range(nbroadcast): - deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) - - cpdef as_scipy_low_level_callable(self): - from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE - if self.tot_out_size > 1: - raise RuntimeError("SciPy LowLevelCallable supports only functions with 1 output") - addr1 = cast(&_scipy_callback_lambda_real, - CFUNCTYPE(c_double, c_int, POINTER(c_double), c_void_p)) - addr2 = cast(self.lambda_visitor.get(), c_void_p) - return create_low_level_callable(self, addr1, addr2) - - cpdef as_ctypes(self): - """ - Returns a tuple with first element being a ctypes function with signature - - void func(double \*output, const double \*input, void \*user_data) - - and second element being a ctypes void pointer. This void pointer needs to be - passed as input to the function as the third argument `user_data`. - """ - from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE - addr1 = cast(&_ctypes_callback_lambda_real, - CFUNCTYPE(c_void_p, POINTER(c_double), POINTER(c_double), c_void_p)) - addr2 = cast(self.lambda_visitor.get(), c_void_p) - return addr1, addr2 - - -cdef class LambdaComplexDouble(_Lambdify): - def __cinit__(self, args, *exprs, cppbool real=True, order='C', cppbool cse=False, cppbool _load=False, dtype=None): - # reject additional arguments - pass - - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_visitor.reset(new symengine.LambdaComplexDoubleVisitor()) - deref(self.lambda_visitor).init(args_, outs_, cse) - - cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=0, int out_offset=0): - deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) - - cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): - cdef double complex[::1] c_inp, c_out - cdef unsigned idx - c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) - c_out = out - for idx in range(nbroadcast): - deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) - - -IF HAVE_SYMENGINE_LLVM: - cdef class LLVMDouble(_LLVMLambdify): - def __cinit__(self, args, *exprs, cppbool real=True, order='C', cppbool cse=False, cppbool _load=False, opt_level=3, dtype=None): - self.opt_level = opt_level - - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_visitor.reset(new symengine.LLVMDoubleVisitor()) - deref(self.lambda_visitor).init(args_, outs_, cse, self.opt_level) - - cdef _load(self, const string &s): - self.lambda_visitor.reset(new symengine.LLVMDoubleVisitor()) - deref(self.lambda_visitor).loads(s) - - def __reduce__(self): - """ - Interface for pickle. Note that the resulting object is platform dependent. - """ - cdef bytes s = deref(self.lambda_visitor).dumps() - return llvm_loading_func, (self.args_size, self.tot_out_size, self.out_shapes, self.real, \ - self.n_exprs, self.order, self.accum_out_sizes, self.numpy_dtype, s) - - cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=0, int out_offset=0): - deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) - - cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): - cdef double[::1] c_inp, c_out - cdef unsigned idx - c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) - c_out = out - for idx in range(nbroadcast): - deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) - - cpdef as_scipy_low_level_callable(self): - from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE - if not self.real: - raise RuntimeError("Lambda function has to be real") - if self.tot_out_size > 1: - raise RuntimeError("SciPy LowLevelCallable supports only functions with 1 output") - addr1 = cast(&_scipy_callback_llvm_real, - CFUNCTYPE(c_double, c_int, POINTER(c_double), c_void_p)) - addr2 = cast(self.lambda_visitor.get(), c_void_p) - return create_low_level_callable(self, addr1, addr2) - - cpdef as_ctypes(self): - """ - Returns a tuple with first element being a ctypes function with signature - - void func(double * output, const double *input, void *user_data) - - and second element being a ctypes void pointer. This void pointer needs to be - passed as input to the function as the third argument `user_data`. - """ - from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE - if not self.real: - raise RuntimeError("Lambda function has to be real") - addr1 = cast(&_ctypes_callback_llvm_real, - CFUNCTYPE(c_void_p, POINTER(c_double), POINTER(c_double), c_void_p)) - addr2 = cast(self.lambda_visitor.get(), c_void_p) - return addr1, addr2 - - cdef class LLVMFloat(_LLVMLambdify): - def __cinit__(self, args, *exprs, cppbool real=True, order='C', cppbool cse=False, cppbool _load=False, opt_level=3, dtype=None): - self.opt_level = opt_level - - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_visitor.reset(new symengine.LLVMFloatVisitor()) - deref(self.lambda_visitor).init(args_, outs_, cse, self.opt_level) - - cdef _load(self, const string &s): - self.lambda_visitor.reset(new symengine.LLVMFloatVisitor()) - deref(self.lambda_visitor).loads(s) - - def __reduce__(self): - """ - Interface for pickle. Note that the resulting object is platform dependent. - """ - cdef bytes s = deref(self.lambda_visitor).dumps() - return llvm_float_loading_func, (self.args_size, self.tot_out_size, self.out_shapes, self.real, \ - self.n_exprs, self.order, self.accum_out_sizes, self.numpy_dtype, s) - - cpdef unsafe_real(self, float[::1] inp, float[::1] out, int inp_offset=0, int out_offset=0): - deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) - - cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): - cdef float[::1] c_inp, c_out - cdef unsigned idx - c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) - c_out = out - for idx in range(nbroadcast): - deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) - - IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE: - cdef class LLVMLongDouble(_LLVMLambdify): - def __cinit__(self, args, *exprs, cppbool real=True, order='C', cppbool cse=False, cppbool _load=False, opt_level=3, dtype=None): - self.opt_level = opt_level - - cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_visitor.reset(new symengine.LLVMLongDoubleVisitor()) - deref(self.lambda_visitor).init(args_, outs_, cse, self.opt_level) - - cdef _load(self, const string &s): - self.lambda_visitor.reset(new symengine.LLVMLongDoubleVisitor()) - deref(self.lambda_visitor).loads(s) - - def __reduce__(self): - """ - Interface for pickle. Note that the resulting object is platform dependent. - """ - cdef bytes s = deref(self.lambda_visitor).dumps() - return llvm_long_double_loading_func, (self.args_size, self.tot_out_size, self.out_shapes, self.real, \ - self.n_exprs, self.order, self.accum_out_sizes, self.numpy_dtype, s) - - cpdef unsafe_real(self, long double[::1] inp, long double[::1] out, int inp_offset=0, int out_offset=0): - deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) - - cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): - cdef long double[::1] c_inp, c_out - cdef unsigned idx - c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) - c_out = out - for idx in range(nbroadcast): - deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) - - def llvm_loading_func(*args): - return LLVMDouble(args, _load=True) - - def llvm_float_loading_func(*args): - return LLVMFloat(args, _load=True) - - IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE: - def llvm_long_double_loading_func(*args): - return LLVMLongDouble(args, _load=True) - -def Lambdify(args, *exprs, cppbool real=True, backend=None, order='C', - as_scipy=False, cse=False, dtype=None, **kwargs): - """ - Lambdify instances are callbacks that numerically evaluate their symbolic - expressions from user provided input (real or complex) into (possibly user - provided) output buffers (real or complex). Multidimensional data are - processed in their most cache-friendly way (i.e. "ravelled"). - - Parameters - ---------- - args: iterable of Symbols - \*exprs: array_like of expressions - the shape of exprs is preserved - real : bool - Whether datatype is ``double`` (``double complex`` otherwise). - backend : str - 'llvm' or 'lambda'. When ``None`` the environment variable - 'SYMENGINE_LAMBDIFY_BACKEND' is used (taken as 'llvm' if available, otherwise 'lambda'). - order : 'C' or 'F' - C- or Fortran-contiguous memory layout. Note that this affects - broadcasting: e.g. a (m, n) matrix taking 3 arguments and given a - (k, l, 3) (C-contiguous) input will give a (k, l, m, n) shaped output, - whereas a (3, k, l) (C-contiguous) input will give a (m, n, k, l) shaped - output. If ``None`` order is taken as ``self.order`` (from initialization). - as_scipy : bool - return a SciPy LowLevelCallable which can be used in SciPy's integrate - methods - cse : bool - Run Common Subexpression Elimination on the output before generating - the callback. - dtype : numpy.dtype type - - Returns - ------- - callback instance with signature f(inp, out=None) - - Examples - -------- - >>> from symengine import var, Lambdify - >>> var('x y z') - >>> f = Lambdify([x, y, z], [x+y+z, x*y*z]) - >>> f([2, 3, 4]) - [ 9., 24.] - >>> out = np.array(2) - >>> f(x, out); out - [ 9., 24.] - - """ - if backend is None: - IF HAVE_SYMENGINE_LLVM: - backend_default = 'llvm' if real else 'lambda' - ELSE: - backend_default = 'lambda' - backend = os.getenv('SYMENGINE_LAMBDIFY_BACKEND', backend_default) - if backend == "llvm": - IF HAVE_SYMENGINE_LLVM: - if dtype == None: - dtype = np.float64 - if dtype == np.float64: - ret = LLVMDouble(args, *exprs, real=real, order=order, cse=cse, dtype=np.float64, **kwargs) - elif dtype == np.float32: - ret = LLVMFloat(args, *exprs, real=real, order=order, cse=cse, dtype=np.float32, **kwargs) - elif dtype == np.longdouble: - IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE: - ret = LLVMLongDouble(args, *exprs, real=real, order=order, cse=cse, dtype=np.longdouble, **kwargs) - ELSE: - raise ValueError("Long double not supported on this platform") - else: - raise ValueError("Unknown numpy dtype.") - - if as_scipy: - return ret.as_scipy_low_level_callable() - return ret - ELSE: - raise ValueError("""llvm backend is chosen, but symengine is not compiled - with llvm support.""") - elif backend == "lambda": - pass - else: - warnings.warn("Unknown SymEngine backend: %s\nUsing backend='lambda'" % backend) - if real: - ret = LambdaDouble(args, *exprs, real=real, order=order, cse=cse, **kwargs) - else: - ret = LambdaComplexDouble(args, *exprs, real=real, order=order, cse=cse, **kwargs) - if as_scipy: - return ret.as_scipy_low_level_callable() - return ret - - -def LambdifyCSE(args, *exprs, order='C', **kwargs): - """ Analogous with Lambdify but performs common subexpression elimination. - """ - warnings.warn("LambdifyCSE is deprecated. Use Lambdify(..., cse=True)", DeprecationWarning) - return Lambdify(args, *exprs, cse=True, order=order, **kwargs) - - -def ccode(expr): - cdef Basic expr_ = sympify(expr) - return symengine.ccode(deref(expr_.thisptr)).decode("utf-8") - - -def piecewise(*v): - cdef symengine.PiecewiseVec vec - cdef pair[rcp_const_basic, RCP[symengine.const_Boolean]] p - cdef Basic e - cdef Boolean b - for expr, rel in v: - e = sympify(expr) - b = sympify(rel) - p.first = e.thisptr - p.second = symengine.rcp_static_cast_Boolean(b.thisptr) - vec.push_back(p) - return c2py(symengine.piecewise(move[symengine.PiecewiseVec](vec))) - - -def interval(start, end, left_open=False, right_open=False): - if isinstance(start, NegativeInfinity): - left_open = True - if isinstance(end, Infinity): - right_open = True - cdef Number start_ = sympify(start) - cdef Number end_ = sympify(end) - cdef cppbool left_open_ = left_open - cdef cppbool right_open_ = right_open - cdef RCP[const symengine.Number] n1 = symengine.rcp_static_cast_Number(start_.thisptr) - cdef RCP[const symengine.Number] n2 = symengine.rcp_static_cast_Number(end_.thisptr) - return c2py(symengine.interval(n1, n2, left_open_, right_open_)) - - -def emptyset(): - return c2py((symengine.emptyset())) - - -def universalset(): - return c2py((symengine.universalset())) - - -def reals(): - return c2py((symengine.reals())) - - -def rationals(): - return c2py((symengine.rationals())) - - -def integers(): - return c2py((symengine.integers())) - - -def finiteset(*args): - cdef symengine.set_basic s - cdef Basic e_ - for e in args: - e_ = sympify(e) - s.insert((e_.thisptr)) - return c2py((symengine.finiteset(s))) - - -def contains(expr, sset): - cdef Basic expr_ = sympify(expr) - cdef Set sset_ = sympify(sset) - cdef RCP[const symengine.Set] s = symengine.rcp_static_cast_Set(sset_.thisptr) - return c2py((symengine.contains(expr_.thisptr, s))) - - -cdef tribool_py(tribool value): - if is_indeterminate(value): - return None - elif is_true(value): - return True - elif is_false(value): - return False - else: - raise RuntimeError("Internal error in symengine.py, tribool got a fourth value.") - - -def is_zero(expr): - cdef Basic expr_ = sympify(expr) - cdef tribool tbool = symengine.is_zero(deref(expr_.thisptr)) - return tribool_py(tbool) - - -def is_positive(expr): - cdef Basic expr_ = sympify(expr) - cdef tribool tbool = symengine.is_positive(deref(expr_.thisptr)) - return tribool_py(tbool) - - -def is_negative(expr): - cdef Basic expr_ = sympify(expr) - cdef tribool tbool = symengine.is_negative(deref(expr_.thisptr)) - return tribool_py(tbool) - - -def is_nonpositive(expr): - cdef Basic expr_ = sympify(expr) - cdef tribool tbool = symengine.is_nonpositive(deref(expr_.thisptr)) - return tribool_py(tbool) - - -def is_nonnegative(expr): - cdef Basic expr_ = sympify(expr) - cdef tribool tbool = symengine.is_nonnegative(deref(expr_.thisptr)) - return tribool_py(tbool) - - -def is_real(expr): - cdef Basic expr_ = sympify(expr) - cdef tribool tbool = symengine.is_real(deref(expr_.thisptr)) - return tribool_py(tbool) - - -def set_union(*args): - cdef symengine.set_set s - cdef Set e_ - for e in args: - e_ = sympify(e) - s.insert(symengine.rcp_static_cast_Set(e_.thisptr)) - return c2py((symengine.set_union(s))) - - -def set_intersection(*args): - cdef symengine.set_set s - cdef Set e_ - for e in args: - e_ = sympify(e) - s.insert(symengine.rcp_static_cast_Set(e_.thisptr)) - return c2py((symengine.set_intersection(s))) - - -def set_complement(universe, container): - cdef Set universe_ = sympify(universe) - cdef Set container_ = sympify(container) - cdef RCP[const symengine.Set] u = symengine.rcp_static_cast_Set(universe_.thisptr) - cdef RCP[const symengine.Set] c = symengine.rcp_static_cast_Set(container_.thisptr) - return c2py((symengine.set_complement(u, c))) - - -def set_complement_helper(container, universe): - cdef Set container_ = sympify(container) - cdef Set universe_ = sympify(universe) - cdef RCP[const symengine.Set] c = symengine.rcp_static_cast_Set(container_.thisptr) - cdef RCP[const symengine.Set] u = symengine.rcp_static_cast_Set(universe_.thisptr) - return c2py((symengine.set_complement_helper(c, u))) - - -def conditionset(sym, condition): - cdef Basic sym_ = sympify(sym) - cdef Boolean condition_ = sympify(condition) - cdef RCP[const symengine.Boolean] c = symengine.rcp_static_cast_Boolean(condition_.thisptr) - return c2py((symengine.conditionset(sym_.thisptr, c))) - - -def imageset(sym, expr, base): - cdef Basic sym_ = sympify(sym) - cdef Basic expr_ = sympify(expr) - cdef Set base_ = sympify(base) - cdef RCP[const symengine.Set] b = symengine.rcp_static_cast_Set(base_.thisptr) - return c2py((symengine.imageset(sym_.thisptr, expr_.thisptr, b))) - - -universal_set_singleton = UniversalSet() -integers_singleton = Integers() -rationals_singleton = Rationals() -reals_singleton = Reals() -empty_set_singleton = EmptySet() - - -def solve(f, sym, domain=None): - cdef Basic f_ = sympify(f) - cdef Basic sym_ = sympify(sym) - require(sym_, Symbol) - cdef RCP[const symengine.Symbol] x = symengine.rcp_static_cast_Symbol(sym_.thisptr) - if domain is None: - return c2py((symengine.solve(f_.thisptr, x))) - cdef Set domain_ = sympify(domain) - cdef RCP[const symengine.Set] d = symengine.rcp_static_cast_Set(domain_.thisptr) - return c2py((symengine.solve(f_.thisptr, x, d))) - - -def linsolve(eqs, syms): - """ - Solve a set of linear equations given as an iterable `eqs` - which are linear w.r.t the symbols given as an iterable `syms` - """ - cdef symengine.vec_basic eqs_ = iter_to_vec_basic(eqs) - cdef symengine.vec_sym syms_ - cdef RCP[const symengine.Symbol] sym_ - cdef Symbol B - for sym in syms: - B = sympify(sym) - sym_ = symengine.rcp_static_cast_Symbol(B.thisptr) - syms_.push_back(sym_) - if syms_.size() != eqs_.size(): - raise RuntimeError("Number of equations and symbols do not match") - cdef symengine.vec_basic ret = symengine.linsolve(eqs_, syms_) - return vec_basic_to_tuple(ret) - - -def cse(exprs): - cdef symengine.vec_basic vec - cdef symengine.vec_pair replacements - cdef symengine.vec_basic reduced_exprs - cdef Basic b - for expr in exprs: - b = sympify(expr) - vec.push_back(b.thisptr) - symengine.cse(replacements, reduced_exprs, vec) - return (vec_pair_to_list(replacements), vec_basic_to_list(reduced_exprs)) - -def latex(expr): - cdef DenseMatrixBase mat_expr - cdef Basic basic_expr - if isinstance(expr, DenseMatrixBase): - mat_expr = expr - return symengine.latex(deref(symengine.static_cast_DenseMatrix(mat_expr.thisptr)), 20, 12).decode("utf-8") - else: - basic_expr = sympify(expr) - return symengine.latex(deref(basic_expr.thisptr)).decode("utf-8") - -def unicode(expr): - cdef Basic basic_expr - basic_expr = sympify(expr) - return symengine.unicode(deref(basic_expr.thisptr)).decode("utf-8") - -cdef _flattened_vec(symengine.vec_basic &vec, exprs): - cdef Basic b - if is_sequence(exprs): - for expr in exprs: - _flattened_vec(vec, expr) - else: - b = sympify(exprs) - vec.push_back(b.thisptr) - - -def count_ops(*exprs): - cdef symengine.vec_basic vec - _flattened_vec(vec, exprs) - return symengine.count_ops(vec) - - -# Turn on nice stacktraces: -symengine.print_stack_on_segfault() diff --git a/symengine/printing.py b/symengine/printing.py deleted file mode 100644 index 4d16d0f2..00000000 --- a/symengine/printing.py +++ /dev/null @@ -1,33 +0,0 @@ -from .lib.symengine_wrapper import ccode, sympify, Basic, repr_latex as _repr_latex - -class CCodePrinter: - - def doprint(self, expr, assign_to=None): - if not isinstance(assign_to, (Basic, type(None), str)): - raise TypeError("{} cannot assign to object of type {}".format( - type(self).__name__, type(assign_to))) - - expr = sympify(expr) - if not assign_to: - if expr.is_Matrix: - raise RuntimeError("Matrices need a assign_to parameter") - return ccode(expr) - - assign_to = str(assign_to) - if not expr.is_Matrix: - return f"{assign_to} = {ccode(expr)};" - - code_lines = [] - for i, element in enumerate(expr): - code_line = f'{assign_to}[{i}] = {element};' - code_lines.append(code_line) - return '\n'.join(code_lines) - - -def init_printing(pretty_print=True, use_latex=True): - if pretty_print: - if not use_latex: - raise RuntimeError("Only latex is supported for pretty printing") - _repr_latex[0] = True - else: - _repr_latex[0] = False diff --git a/symengine/sympy_compat.py b/symengine/sympy_compat.py deleted file mode 100644 index 57e12c78..00000000 --- a/symengine/sympy_compat.py +++ /dev/null @@ -1,4 +0,0 @@ -import warnings -warnings.warn("sympy_compat module is deprecated. Use `import symengine` instead", DeprecationWarning, - stacklevel=2) -from symengine import * diff --git a/symengine/test_utilities.py b/symengine/test_utilities.py deleted file mode 100644 index cd3eeaa4..00000000 --- a/symengine/test_utilities.py +++ /dev/null @@ -1,95 +0,0 @@ -import sys - -try: - import py - from py.test import skip, raises - USE_PYTEST = getattr(sys, '_running_pytest', False) -except ImportError: - USE_PYTEST = False - -if not USE_PYTEST: - def raises(expectedException, code=None): - """ - Tests that ``code`` raises the exception ``expectedException``. - - ``code`` may be a callable, such as a lambda expression or function - name. - - If ``code`` is not given or None, ``raises`` will return a context - manager for use in ``with`` statements; the code to execute then - comes from the scope of the ``with``. - - ``raises()`` does nothing if the callable raises the expected - exception, otherwise it raises an AssertionError. - - Examples - ======== - - >>> from symengine.pytest import raises - - >>> raises(ZeroDivisionError, lambda: 1/0) - >>> raises(ZeroDivisionError, lambda: 1/2) - Traceback (most recent call last): - ... - AssertionError: DID NOT RAISE - - >>> with raises(ZeroDivisionError): - ... n = 1/0 - >>> with raises(ZeroDivisionError): - ... n = 1/2 - Traceback (most recent call last): - ... - AssertionError: DID NOT RAISE - - Note that you cannot test multiple statements via - ``with raises``: - - >>> with raises(ZeroDivisionError): - ... n = 1/0 # will execute and raise, aborting the ``with`` - ... n = 9999/0 # never executed - - This is just what ``with`` is supposed to do: abort the - contained statement sequence at the first exception and let - the context manager deal with the exception. - - To test multiple statements, you'll need a separate ``with`` - for each: - - >>> with raises(ZeroDivisionError): - ... n = 1/0 # will execute and raise - >>> with raises(ZeroDivisionError): - ... n = 9999/0 # will also execute and raise - - """ - if code is None: - return RaisesContext(expectedException) - elif callable(code): - try: - code() - except expectedException: - return - raise AssertionError("DID NOT RAISE") - elif isinstance(code, str): - raise TypeError( - '\'raises(xxx, "code")\' has been phased out; ' - 'change \'raises(xxx, "expression")\' ' - 'to \'raises(xxx, lambda: expression)\', ' - '\'raises(xxx, "statement")\' ' - 'to \'with raises(xxx): statement\'') - else: - raise TypeError( - 'raises() expects a callable for the 2nd argument.') - - class RaisesContext: - def __init__(self, expectedException): - self.expectedException = expectedException - - def __enter__(self): - return None - - def __exit__(self, exc_type, exc_value, traceback): - if exc_type is None: - raise AssertionError("DID NOT RAISE") - return issubclass(exc_type, self.expectedException) - - diff --git a/symengine/tests/CMakeLists.txt b/symengine/tests/CMakeLists.txt deleted file mode 100644 index 4f19093b..00000000 --- a/symengine/tests/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine/tests) -install( - FILES - __init__.py - test_arit.py - test_cse.py - test_dict_basic.py - test_eval.py - test_expr.py - test_functions.py - test_lambdify.py - test_logic.py - test_matrices.py - test_ntheory.py - test_number.py - test_pickling.py - test_printing.py - test_sage.py - test_series_expansion.py - test_sets.py - test_solve.py - test_subs.py - test_symbol.py - test_sympify.py - test_sympy_compat.py - test_sympy_conv.py - test_var.py - DESTINATION - ${PY_PATH} -) diff --git a/symengine/tests/__init__.py b/symengine/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/symengine/tests/test_arit.py b/symengine/tests/test_arit.py deleted file mode 100644 index 931b8adb..00000000 --- a/symengine/tests/test_arit.py +++ /dev/null @@ -1,261 +0,0 @@ -from symengine.test_utilities import raises - -from symengine import (Symbol, Integer, Add, Mul, Pow, Rational, sqrt, - symbols, S, I, count_ops, floor) - - -def test_arit1(): - x = Symbol("x") - y = Symbol("y") - e = x + y - e = x * y - e = Integer(2)*x - e = 2*x - e = x + 1 - e = 1 + x - - -def test_arit2(): - x = Symbol("x") - y = Symbol("y") - assert x+x == Integer(2) * x - assert x+x != Integer(3) * x - assert x+y == y+x - assert x+x == 2*x - assert x+x == x*2 - assert x+x+x == 3*x - assert x+y+x+x == 3*x+y - - assert not x+x == 3*x - assert not x+x != 2*x - - -def test_arit3(): - x = Symbol("x") - y = Symbol("y") - raises(TypeError, lambda: ("x"*x)) - - -def test_arit4(): - x = Symbol("x") - y = Symbol("y") - assert x*x == x**2 - assert x*y == y*x - assert x*x*x == x**3 - assert x*y*x*x == x**3*y - - -def test_arit5(): - x = Symbol("x") - y = Symbol("y") - e = (x+y)**2 - f = e.expand() - assert e == (x+y)**2 - assert e != x**2 + 2*x*y + y**2 - assert isinstance(e, Pow) - assert f == x**2 + 2*x*y + y**2 - assert isinstance(f, Add) - - -def test_arit6(): - x = Symbol("x") - y = Symbol("y") - e = x + y - assert str(e) == "x + y" or "y + x" - e = x * y - assert str(e) == "x*y" or "y*x" - e = Integer(2)*x - assert str(e) == "2*x" - e = 2*x - assert str(e) == "2*x" - - -def test_arit7(): - x = Symbol("x") - y = Symbol("y") - assert x - x == 0 - assert x - y != y - x - assert 2*x - x == x - assert 3*x - x == 2*x - - assert 2*x*y - x*y == x*y - - -def test_arit8(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - assert x**y * x**x == x**(x+y) - assert x**y * x**x * x**z == x**(x+y+z) - assert x**y - x**y == 0 - - assert x**2 / x == x - assert y*x**2 / (x*y) == x - assert (2 * x**3 * y**2 * z)**3 / 8 == x**9 * y**6 * z**3 - assert (2*y**(-2*x**2)) * (3*y**(2*x**2)) == 6 - - -def test_unary(): - x = Symbol("x") - assert -x == 0 - x - assert +x == x - - -def test_expand1(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - assert ((2*x+y)**2).expand() == 4*x**2 + 4*x*y + y**2 - assert (x**2)**3 == x**6 - assert ((2*x**2+3*y)**2).expand() == 4*x**4 + 12*x**2*y + 9*y**2 - assert ((2*x/3+y/4)**2).expand() == 4*x**2/9 + x*y/3 + y**2/16 - - -def test_arit9(): - x = Symbol("x") - y = Symbol("y") - assert 1/x == 1/x - assert 1/x != 1/y - - -def test_expand2(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - assert ((1/(y*z) - y*z)*y*z).expand() == 1-(y*z)**2 - assert (2*(x + 2*(y + z))).expand(deep=False) == 2*x + 4*(y+z) - ex = x + 2*(y + z) - assert ex.expand(deep=False) == ex - - -def test_expand3(): - x = Symbol("x") - y = Symbol("y") - assert ((1/(x*y) - x*y+2)*(1+x*y)).expand() == 3 + 1/(x*y) + x*y - (x*y)**2 - - -def test_args(): - x = Symbol("x") - y = Symbol("y") - assert (x**2).args == (x, 2) - assert (x**2 + 5).args == (5, x**2) - assert set((x**2 + 2*x*y + 5).args) == {x**2, 2*x*y, Integer(5)} - assert (2*x**2).args == (2, x**2) - assert set((2*x**2*y).args) == {Integer(2), x**2, y} - - -def test_atoms(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - assert (x**2).atoms() == {x} - assert (x**2).atoms(Symbol) == {x} - assert (x ** y + z).atoms() == {x, y, z} - assert (x**y + z).atoms(Symbol) == {x, y, z} - - -def test_free_symbols(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - assert (x**2).free_symbols == {x} - assert (x**y + z).free_symbols == {x, y, z} - - -def test_as_numer_denom(): - x, y = Rational(17, 26).as_numer_denom() - assert x == Integer(17) - assert y == Integer(26) - - x, y = Integer(-5).as_numer_denom() - assert x == Integer(-5) - assert y == Integer(1) - - -def test_floor(): - exprs = [Symbol("x"), Symbol("y"), Integer(2), Rational(-3, 5), Integer(-3)] - - for x in exprs: - for y in exprs: - assert x // y == floor(x / y) - assert x == y * (x // y) + x % y - - -def test_as_real_imag(): - x, y = (5 + 6 * I).as_real_imag() - - assert x == 5 - assert y == 6 - - -def test_from_args(): - x = Symbol("x") - y = Symbol("y") - - assert Add._from_args([]) == 0 - assert Add._from_args([x]) == x - assert Add._from_args([x, y]) == x + y - - assert Mul._from_args([]) == 1 - assert Mul._from_args([x]) == x - assert Mul._from_args([x, y]) == x * y - - -def test_make_args(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - - assert Add.make_args(x) == (x,) - assert Mul.make_args(x) == (x,) - - assert Add.make_args(x*y*z) == (x*y*z,) - assert Mul.make_args(x*y*z) == (x*y*z).args - - assert Add.make_args(x + y + z) == (x + y + z).args - assert Mul.make_args(x + y + z) == (x + y + z,) - - assert Add.make_args((x + y)**z) == ((x + y)**z,) - assert Mul.make_args((x + y)**z) == ((x + y)**z,) - - -def test_Pow_base_exp(): - x = Symbol("x") - y = Symbol("y") - e = Pow(x + y, 2) - assert isinstance(e, Pow) - assert e.exp == 2 - assert e.base == x + y - - assert sqrt(x - 1).as_base_exp() == (x - 1, Rational(1, 2)) - - -def test_copy(): - b = Symbol("b") - a = b.copy() - assert a is b - assert type(a) == type(b) - - -def test_special_constants(): - assert S.Zero == Integer(0) - assert S.One == Integer(1) - assert S.NegativeOne == Integer(-1) - assert S.Half == Rational(1, 2) - - -def test_bool(): - x = Symbol('x') - if (x**2).args[1] > 0: - assert True - if (x**2).args[1] < 0: - assert False - - -def test_count_ops(): - x, y = symbols("x, y") - assert count_ops(x+y) == 1 - assert count_ops((x+y, x*y)) == 2 - assert count_ops([[x**y], [x+y-1]]) == 3 - assert count_ops(x+y, x*y) == 2 - diff --git a/symengine/tests/test_cse.py b/symengine/tests/test_cse.py deleted file mode 100644 index 20dcd2a8..00000000 --- a/symengine/tests/test_cse.py +++ /dev/null @@ -1,17 +0,0 @@ -from symengine import cse, sqrt, symbols - -def test_cse_single(): - x, y, x0 = symbols("x, y, x0") - e = pow(x + y, 2) + sqrt(x + y) - substs, reduced = cse([e]) - assert substs == [(x0, x + y)] - assert reduced == [sqrt(x0) + x0**2] - - -def test_multiple_expressions(): - w, x, y, z, x0 = symbols("w, x, y, z, x0") - e1 = (x + y)*z - e2 = (x + y)*w - substs, reduced = cse([e1, e2]) - assert substs == [(x0, x + y)] - assert reduced == [x0*z, x0*w] diff --git a/symengine/tests/test_dict_basic.py b/symengine/tests/test_dict_basic.py deleted file mode 100644 index d1e5ab63..00000000 --- a/symengine/tests/test_dict_basic.py +++ /dev/null @@ -1,28 +0,0 @@ -from symengine.test_utilities import raises - -from symengine import symbols, DictBasic, sin, Integer - - -def test_DictBasic(): - x, y, z = symbols("x y z") - d = DictBasic({x: 2, y: z}) - - assert str(d) == "{x: 2, y: z}" or str(d) == "{y: z, x: 2}" - assert d[x] == 2 - - raises(KeyError, lambda: d[2*z]) - if 2*z in d: - assert False - - d[2*z] = x - assert d[2*z] == x - if 2*z not in d: - assert False - assert set(d.items()) == {(2*z, x), (x, Integer(2)), (y, z)} - - del d[x] - assert set(d.keys()) == {2*z, y} - assert set(d.values()) == {x, z} - - e = y + sin(2*z) - assert e.subs(d) == z + sin(x) diff --git a/symengine/tests/test_eval.py b/symengine/tests/test_eval.py deleted file mode 100644 index 24b062f1..00000000 --- a/symengine/tests/test_eval.py +++ /dev/null @@ -1,67 +0,0 @@ -from symengine.test_utilities import raises -from symengine import (Symbol, sin, cos, Integer, Add, I, RealDouble, ComplexDouble, sqrt) - -from unittest.case import SkipTest - -def test_eval_double1(): - x = Symbol("x") - y = Symbol("y") - e = sin(x)**2 + cos(x)**2 - e = e.subs(x, 7) - assert abs(e.n(real=True) - 1) < 1e-9 - assert abs(e.n() - 1) < 1e-9 - - -def test_eval_double2(): - x = Symbol("x") - e = sin(x)**2 + sqrt(2) - raises(RuntimeError, lambda: e.n(real=True)) - assert abs(e.n() - sin(x)**2.0 - 1.414) < 1e-3 - -def test_n(): - x = Symbol("x") - raises(RuntimeError, lambda: x.n(real=True)) - assert x.n() == x + 0.0 - - x = 2 + I - raises(RuntimeError, lambda: (x.n(real=True))) - - x = sqrt(Integer(4)) - y = RealDouble(2.0) - assert x.n(real=True) == y - - x = 1 + 2*I - y = 1.0 + 2.0*I - assert x.n() == y - - -def test_n_mpfr(): - x = sqrt(Integer(2)) - try: - from symengine import RealMPFR - y = RealMPFR('1.41421356237309504880169', 75) - assert x.n(75, real=True) == y - except ImportError: - raises(ValueError, lambda: (x.n(75, real=True))) - raises(ValueError, lambda: (x.n(75))) - raise SkipTest("No MPFR support") - - -def test_n_mpc(): - x = sqrt(Integer(2)) + 3*I - try: - from symengine import ComplexMPC - y = ComplexMPC('1.41421356237309504880169', '3.0', 75) - assert x.n(75) == y - except ImportError: - raises(Exception, lambda: (x.n(75, real=True))) - raises(ValueError, lambda: (x.n(75, real=False))) - raises(ValueError, lambda: (x.n(75))) - raise SkipTest("No MPC support") - - -def test_rel(): - x = Symbol("x") - y = Symbol("y") - ex = (x + y < x) - assert repr(ex) == "x + y < x" diff --git a/symengine/tests/test_expr.py b/symengine/tests/test_expr.py deleted file mode 100644 index 8cbf4ab7..00000000 --- a/symengine/tests/test_expr.py +++ /dev/null @@ -1,28 +0,0 @@ -from symengine import Symbol, Integer, oo -from symengine.test_utilities import raises - - -def test_as_coefficients_dict(): - x = Symbol('x') - y = Symbol('y') - check = [x, y, x*y, Integer(1)] - assert [(3*x + 2*x + y + 3).as_coefficients_dict()[i] for i in check] == \ - [5, 1, 0, 3] - assert [(3*x*y).as_coefficients_dict()[i] for i in check] == \ - [0, 0, 3, 0] - assert (3.0*x*y).as_coefficients_dict()[3.0*x*y] == 0 - assert (3.0*x*y).as_coefficients_dict()[x*y] == 3.0 - - -def test_as_powers_dict(): - x = Symbol('x') - y = Symbol('y') - - assert (2*x**y).as_powers_dict() == {2: 1, x: y} - assert (2*x**2*y**3).as_powers_dict() == {2: 1, x: 2, y: 3} - assert (-oo).as_powers_dict() == {Integer(-1): 1, oo: 1} - assert (x**y).as_powers_dict() == {x: y} - assert ((1/Integer(2))**y).as_powers_dict() == {Integer(2): -y} - assert (x*(1/Integer(2))**y).as_powers_dict() == {x: Integer(1), Integer(2): -y} - assert (2**y).as_powers_dict() == {2: y} - assert (2**-y).as_powers_dict() == {2: -y} diff --git a/symengine/tests/test_functions.py b/symengine/tests/test_functions.py deleted file mode 100644 index 207add98..00000000 --- a/symengine/tests/test_functions.py +++ /dev/null @@ -1,432 +0,0 @@ -from symengine import ( - Symbol, sin, cos, sqrt, Add, Mul, function_symbol, Integer, log, E, symbols, I, - Rational, EulerGamma, Function, Subs, Derivative, LambertW, zeta, dirichlet_eta, - zoo, pi, KroneckerDelta, LeviCivita, erf, erfc, oo, lowergamma, uppergamma, exp, - loggamma, beta, polygamma, digamma, trigamma, sign, floor, ceiling, conjugate, - nan, Float, UnevaluatedExpr -) -from symengine.test_utilities import raises - -import unittest - -try: - import sympy - from sympy.core.cache import clear_cache - import atexit - atexit.register(clear_cache) - have_sympy = True -except ImportError: - have_sympy = False - -def test_sin(): - x = Symbol("x") - e = sin(x) - assert e == sin(x) - assert e != cos(x) - - assert sin(x).diff(x) == cos(x) - assert cos(x).diff(x) == -sin(x) - - e = sqrt(x).diff(x).diff(x) - f = sin(e) - g = f.diff(x).diff(x) - assert isinstance(g, Add) - - -def test_f(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - f = function_symbol("f", x) - g = function_symbol("g", x) - assert f != g - - f = function_symbol("f", x) - g = function_symbol("f", x) - assert f == g - - f = function_symbol("f", x, y) - g = function_symbol("f", y, x) - assert f != g - - f = function_symbol("f", x, y) - g = function_symbol("f", x, y) - assert f == g - - -def test_derivative(): - x = Symbol("x") - y = Symbol("y") - f = function_symbol("f", x) - assert f.diff(x) == function_symbol("f", x).diff(x) - assert f.diff(x).diff(x) == function_symbol("f", x).diff(x).diff(x) - assert f.diff(y) == 0 - assert f.diff(x).args == (f, x) - assert f.diff(x).diff(x).args == (f, x, x) - assert f.diff(x, 0) == f - assert f.diff(x, 0) == Derivative(function_symbol("f", x), x, 0) - raises(ValueError, lambda: f.diff(0)) - raises(ValueError, lambda: f.diff(x, 0, 0)) - raises(ValueError, lambda: f.diff(x, y, 0, 0, x)) - - g = function_symbol("f", y) - assert g.diff(x) == 0 - assert g.diff(y) == function_symbol("f", y).diff(y) - assert g.diff(y).diff(y) == function_symbol("f", y).diff(y).diff(y) - - assert f - function_symbol("f", x) == 0 - - f = function_symbol("f", x, y) - assert f.diff(x).diff(y) == function_symbol("f", x, y).diff(x).diff(y) - assert f.diff(Symbol("z")) == 0 - - s = Derivative(function_symbol("f", x), x) - assert s.expr == function_symbol("f", x) - assert s.variables == (x,) - - fxy = Function("f")(x, y) - assert (1+fxy).has(fxy) - g = Derivative(Function("f")(x, y), x, 2, y, 1) - assert g == fxy.diff(x, x, y) - assert g == fxy.diff(y, 1, x, 2) - assert g == fxy.diff(y, x, 2) - - h = Derivative(Function("f")(x, y), x, 0, y, 1) - assert h == fxy.diff(x, 0, y) - assert h == fxy.diff(y, x, 0) - - i = Derivative(Function("f")(x, y), x, 0, y, 1, x, 1) - assert i == fxy.diff(x, 0, y, x, 1) - assert i == fxy.diff(x, 0, y, x) - assert i == fxy.diff(y, x) - assert i == fxy.diff(y, 1, x, 1) - assert i == fxy.diff(y, 1, x) - - -def test_function(): - x = Symbol("x") - fx = Function("f")(x) - assert fx == function_symbol("f", x) - - raises(TypeError, lambda: Function("f", "x")) - raises(TypeError, lambda: Function("f", x)) - raises(TypeError, lambda: Function()) - - assert fx.name == "f" - - -def test_abs(): - x = Symbol("x") - e = abs(x) - assert e == abs(x) - assert e != cos(x) - - assert abs(5) == 5 - assert abs(-5) == 5 - assert abs(Integer(5)/3) == Integer(5)/3 - assert abs(-Integer(5)/3) == Integer(5)/3 - assert abs(Integer(5)/3+x) != Integer(5)/3 - assert abs(Integer(5)/3+x) == abs(Integer(5)/3+x) - - -def test_abs_diff(): - x = Symbol("x") - y = Symbol("y") - e = abs(x) - assert e.diff(x) != e - assert e.diff(x) != 0 - assert e.diff(y) == 0 - - -def test_Subs(): - x = Symbol("x") - y = Symbol("y") - _x = Symbol("_xi_1") - f = function_symbol("f", 2*x) - assert str(f.diff(x)) == "2*Subs(Derivative(f(_xi_1), _xi_1), (_xi_1), (2*x))" - # TODO: fix me - # assert f.diff(x) == 2 * Subs(Derivative(function_symbol("f", _x), _x), [_x], [2 * x]) - assert Subs(Derivative(function_symbol("f", x, y), x), [x, y], [_x, x]) \ - == Subs(Derivative(function_symbol("f", x, y), x), [y, x], [x, _x]) - - s = f.diff(x)/2 - _xi_1 = Symbol("_xi_1") - assert s.expr == Derivative(function_symbol("f", _xi_1), _xi_1) - assert s.variables == (_xi_1,) - assert s.point == (2*x,) - - -@unittest.skipUnless(have_sympy, "SymPy not installed") -def test_FunctionWrapper(): - import sympy - n, m, theta, phi = sympy.symbols("n, m, theta, phi") - r = sympy.Ynm(n, m, theta, phi) - s = Integer(2)*r - assert isinstance(s, Mul) - assert isinstance(s.args[1]._sympy_(), sympy.Ynm) - - x = symbols("x") - e = x + sympy.Mod(x, 2) - assert str(e) == "x + Mod(x, 2)" - assert isinstance(e, Add) - assert e + sympy.Mod(x, 2) == x + 2*sympy.Mod(x, 2) - - f = e.subs({x : 10}) - assert f == 10 - - f = e.subs({x : 2}) - assert f == 2 - - f = e.subs({x : 100}); - v = f.n(53, real=True); - assert abs(float(v) - 100.00000000) < 1e-7 - - -def test_log(): - x = Symbol("x") - y = Symbol("y") - assert log(E) == 1 - assert log(x, x) == 1 - assert log(x, y) == log(x) / log(y) - - -def test_lambertw(): - assert LambertW(0) == 0 - assert LambertW(E) == 1 - assert LambertW(-1/E) == -1 - assert LambertW(-log(2)/2) == -log(2) - - -def test_zeta(): - x = Symbol("x") - assert zeta(1) == zoo - assert zeta(1, x) == zoo - - assert zeta(0) == Rational(-1, 2) - assert zeta(0, x) == Rational(1, 2) - x - - assert zeta(1, 2) == zoo - assert zeta(1, -7) == zoo - - assert zeta(2, 1) == pi**2/6 - - assert zeta(2) == pi**2/6 - assert zeta(4) == pi**4/90 - assert zeta(6) == pi**6/945 - - assert zeta(2, 2) == pi**2/6 - 1 - assert zeta(4, 3) == pi**4/90 - Rational(17, 16) - assert zeta(6, 4) == pi**6/945 - Rational(47449, 46656) - - assert zeta(-1) == -Rational(1, 12) - assert zeta(-2) == 0 - assert zeta(-3) == Rational(1, 120) - assert zeta(-4) == 0 - assert zeta(-5) == -Rational(1, 252) - - assert zeta(-1, 3) == -Rational(37, 12) - assert zeta(-1, 7) == -Rational(253, 12) - assert zeta(-1, -4) == Rational(119, 12) - assert zeta(-1, -9) == Rational(539, 12) - - assert zeta(-4, 3) == -17 - assert zeta(-4, -8) == 8772 - - assert zeta(0, 1) == -Rational(1, 2) - assert zeta(0, -1) == Rational(3, 2) - - assert zeta(0, 2) == -Rational(3, 2) - assert zeta(0, -2) == Rational(5, 2) - - -def test_dirichlet_eta(): - assert dirichlet_eta(0) == Rational(1, 2) - assert dirichlet_eta(-1) == Rational(1, 4) - assert dirichlet_eta(1) == log(2) - assert dirichlet_eta(2) == pi**2/12 - assert dirichlet_eta(4) == pi**4*Rational(7, 720) - - -def test_kronecker_delta(): - x = Symbol("x") - y = Symbol("y") - assert KroneckerDelta(1, 1) == 1 - assert KroneckerDelta(1, 2) == 0 - assert KroneckerDelta(x, x) == 1 - assert KroneckerDelta(x**2 - y**2, x**2 - y**2) == 1 - assert KroneckerDelta(0, 0) == 1 - assert KroneckerDelta(0, 1) == 0 - - -def test_levi_civita(): - i = Symbol("i") - j = Symbol("j") - assert LeviCivita(1, 2, 3) == 1 - assert LeviCivita(1, 3, 2) == -1 - assert LeviCivita(1, 2, 2) == 0 - assert LeviCivita(i, j, i) == 0 - assert LeviCivita(1, i, i) == 0 - assert LeviCivita(1, 2, 3, 1) == 0 - assert LeviCivita(4, 5, 1, 2, 3) == 1 - assert LeviCivita(4, 5, 2, 1, 3) == -1 - - -def test_erf(): - x = Symbol("x") - y = Symbol("y") - assert erf(nan) == nan - assert erf(oo) == 1 - assert erf(-oo) == -1 - assert erf(0) == 0 - assert erf(-2) == -erf(2) - assert erf(-x*y) == -erf(x*y) - assert erf(-x - y) == -erf(x + y) - - -def test_erfc(): - assert erfc(nan) == nan - assert erfc(oo) == 0 - assert erfc(-oo) == 2 - assert erfc(0) == 1 - - -def test_lowergamma(): - assert lowergamma(1, 2) == 1 - exp(-2) - - -def test_uppergamma(): - assert uppergamma(1, 2) == exp(-2) - assert uppergamma(4, 0) == 6 - - -def test_loggamma(): - assert loggamma(-1) == oo - assert loggamma(-2) == oo - assert loggamma(0) == oo - assert loggamma(1) == 0 - assert loggamma(2) == 0 - assert loggamma(3) == log(2) - - -def test_beta(): - assert beta(3, 2) == beta(2, 3) - - -def test_polygamma(): - assert polygamma(0, -9) == zoo - assert polygamma(0, -9) == zoo - assert polygamma(0, -1) == zoo - assert polygamma(0, 0) == zoo - assert polygamma(0, 1) == -EulerGamma - assert polygamma(0, 7) == Rational(49, 20) - EulerGamma - assert polygamma(1, 1) == pi**2/6 - assert polygamma(1, 2) == pi**2/6 - 1 - assert polygamma(1, 3) == pi**2/6 - Rational(5, 4) - assert polygamma(3, 1) == pi**4 / 15 - assert polygamma(3, 5) == 6*(Rational(-22369, 20736) + pi**4/90) - assert polygamma(5, 1) == 8 * pi**6 / 63 - - -def test_digamma(): - x = Symbol("x") - assert digamma(x) == polygamma(0, x) - assert digamma(0) == zoo - assert digamma(1) == -EulerGamma - - -def test_trigamma(): - x = Symbol("x") - assert trigamma(-2) == zoo - assert trigamma(x) == polygamma(1, x) - - -def test_sign(): - assert sign(1.2) == 1 - assert sign(-1.2) == -1 - assert sign(3*I) == I - assert sign(-3*I) == -I - assert sign(0) == 0 - assert sign(nan) == nan - - -def test_floor(): - x = Symbol("x") - y = Symbol("y") - assert floor(nan) == nan - assert floor(oo) == oo - assert floor(-oo) == -oo - assert floor(0) == 0 - assert floor(1) == 1 - assert floor(-1) == -1 - assert floor(E) == 2 - assert floor(pi) == 3 - assert floor(Rational(1, 2)) == 0 - assert floor(-Rational(1, 2)) == -1 - assert floor(Rational(7, 3)) == 2 - assert floor(-Rational(7, 3)) == -3 - assert floor(Float(17.0)) == 17 - assert floor(-Float(17.0)) == -17 - assert floor(Float(7.69)) == 7 - assert floor(-Float(7.69)) == -8 - assert floor(I) == I - assert floor(-I) == -I - assert floor(2*I) == 2*I - assert floor(-2*I) == -2*I - assert floor(E + pi) == floor(E + pi) - assert floor(I + pi) == floor(I + pi) - assert floor(floor(pi)) == 3 - assert floor(floor(y)) == floor(y) - assert floor(floor(x)) == floor(floor(x)) - assert floor(x) == floor(x) - assert floor(2*x) == floor(2*x) - - -def test_ceiling(): - x = Symbol("x") - y = Symbol("y") - assert ceiling(nan) == nan - assert ceiling(oo) == oo - assert ceiling(-oo) == -oo - assert ceiling(0) == 0 - assert ceiling(1) == 1 - assert ceiling(-1) == -1 - assert ceiling(E) == 3 - assert ceiling(pi) == 4 - assert ceiling(Rational(1, 2)) == 1 - assert ceiling(-Rational(1, 2)) == 0 - assert ceiling(Rational(7, 3)) == 3 - assert ceiling(-Rational(7, 3)) == -2 - assert ceiling(Float(17.0)) == 17 - assert ceiling(-Float(17.0)) == -17 - assert ceiling(Float(7.69)) == 8 - assert ceiling(-Float(7.69)) == -7 - assert ceiling(I) == I - assert ceiling(-I) == -I - assert ceiling(2*I) == 2*I - assert ceiling(-2*I) == -2*I - assert ceiling(E + pi) == ceiling(E + pi) - assert ceiling(I + pi) == ceiling(I + pi) - assert ceiling(ceiling(pi)) == 4 - assert ceiling(ceiling(y)) == ceiling(y) - assert ceiling(ceiling(x)) == ceiling(ceiling(x)) - assert ceiling(x) == ceiling(x) - assert ceiling(2*x) == ceiling(2*x) - - -def test_conjugate(): - assert conjugate(pi) == pi - assert conjugate(I) == -I - - -def test_unevaluated_expr(): - x = Symbol("x") - t = UnevaluatedExpr(x) - assert x + t != 2 * x - assert not t.is_number - assert not t.is_integer - assert not t.is_finite - - t = UnevaluatedExpr(1) - assert t.is_number - assert t.is_integer - assert t.is_finite diff --git a/symengine/tests/test_lambdify.py b/symengine/tests/test_lambdify.py deleted file mode 100644 index fa628a36..00000000 --- a/symengine/tests/test_lambdify.py +++ /dev/null @@ -1,863 +0,0 @@ -import array -import cmath -from functools import reduce -import itertools -from operator import mul -import math - -import symengine as se -from symengine.test_utilities import raises -from symengine import have_numpy -import unittest -from unittest.case import SkipTest - -try: - import sympy - from sympy.core.cache import clear_cache - import atexit - atexit.register(clear_cache) - have_sympy = True -except ImportError: - have_sympy = False - -try: - import scipy - from scipy import LowLevelCallable - have_scipy = True -except ImportError: - have_scipy = False - -if have_numpy: - import numpy as np - -def _size(arr): - try: - return arr.memview.size - except AttributeError: - return len(arr) - - -def isclose(a, b, rtol=1e-13, atol=1e-13): - discr = a - b - toler = (atol + rtol*abs(a)) - return abs(discr) < toler - - -def allclose(vec1, vec2, rtol=1e-13, atol=1e-13): - n1, n2 = _size(vec1), _size(vec2) - if n1 != n2: - return False - - for idx in range(n1): - if not isclose(vec1[idx], vec2[idx], rtol, atol): - return False - return True - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_ravel(): - x = se.symbols('x') - exprs = [x+1, x+2, x+3, 1/x, 1/(x*x), 1/(x**3.0)] - A = se.DenseMatrix(2, 3, exprs) - assert np.all(np.ravel(A, order='C') == exprs) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify(): - n = 7 - args = x, y, z = se.symbols('x y z') - L = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='lambda') - assert allclose(L(range(n, n+len(args))), - [3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)]) - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_with_opt_level(): - args = x, y, z = se.symbols('x y z') - raises(TypeError, lambda: se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='lambda', opt_level=0)) - -def _test_Lambdify_Piecewise(Lambdify): - x = se.symbols('x') - p = se.Piecewise((-x, x<0), (x*x*x, True)) - f = Lambdify([x], [p]) - arr = np.linspace(3, 7) - assert np.allclose(f(-arr).flat, arr, atol=1e-14, rtol=1e-15) - assert np.allclose(f(arr).flat, arr**3, atol=1e-14, rtol=1e-15) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_Piecewise(): - _test_Lambdify_Piecewise(lambda *args: se.Lambdify(*args, backend='lambda')) - if se.have_llvm: - _test_Lambdify_Piecewise(lambda *args: se.Lambdify(*args, backend='llvm')) - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_LLVM(): - n = 7 - args = x, y, z = se.symbols('x y z') - if not se.have_llvm: - raises(ValueError, lambda: se.Lambdify(args, [x+y+z, x**2, - (x-y)/z, x*y*z], - backend='llvm')) - raise SkipTest("No LLVM support") - L = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='llvm') - assert allclose(L(range(n, n+len(args))), - [3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)]) - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_LLVM_with_opt_level(): - for opt_level in range(4): - n = 7 - args = x, y, z = se.symbols('x y z') - if not se.have_llvm: - raises(ValueError, lambda: se.Lambdify(args, [x+y+z, x**2, - (x-y)/z, x*y*z], - backend='llvm', opt_level=opt_level)) - raise SkipTest("No LLVM support") - L = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='llvm', opt_level=opt_level) - assert allclose(L(range(n, n+len(args))), - [3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)]) - -def _get_2_to_2by2(): - args = x, y = se.symbols('x y') - exprs = np.array([[x+y+1.0, x*y], - [x/y, x**y]]) - L = se.Lambdify(args, exprs) - - def check(A, inp): - X, Y = inp - assert abs(A[0, 0] - (X+Y+1.0)) < 1e-15 - assert abs(A[0, 1] - (X*Y)) < 1e-15 - assert abs(A[1, 0] - (X/Y)) < 1e-15 - assert abs(A[1, 1] - (X**Y)) < 1e-13 - return L, check - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_2dim(): - lmb, check = _get_2_to_2by2() - for inp in [(5, 7), np.array([5, 7]), [5.0, 7.0]]: - A = lmb(inp) - assert A.shape == (2, 2) - check(A, inp) - - -def _get_array(): - X, Y, Z = inp = array.array('d', [1, 2, 3]) - args = x, y, z = se.symbols('x y z') - exprs = [x+y+z, se.sin(x)*se.log(y)*se.exp(z)] - ref = [X+Y+Z, math.sin(X)*math.log(Y)*math.exp(Z)] - - def check(arr): - assert all([abs(x1-x2) < 1e-13 for x1, x2 in zip(ref, arr)]) - return args, exprs, inp, check - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_array(): - args, exprs, inp, check = _get_array() - lmb = se.Lambdify(args, exprs) - out = lmb(inp) - check(out) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_numpy_array_out_exceptions(): - args, exprs, inp, check = _get_array() - assert len(args) == 3 and len(exprs) == 2 - lmb = se.Lambdify(args, exprs) - - all_right = np.empty(len(exprs)) - lmb(inp, out=all_right) - - too_short = np.empty(len(exprs) - 1) - raises(ValueError, lambda: (lmb(inp, out=too_short))) - - wrong_dtype = np.empty(len(exprs), dtype=int) - raises(ValueError, lambda: (lmb(inp, out=wrong_dtype))) - - read_only = np.empty(len(exprs)) - read_only.flags['WRITEABLE'] = False - raises(ValueError, lambda: (lmb(inp, out=read_only))) - - all_right_broadcast_C = np.empty((4, len(exprs)), order='C') - inp_bcast = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] - lmb(np.array(inp_bcast), out=all_right_broadcast_C) - - noncontig_broadcast = np.empty((4, len(exprs), 3)).transpose((1, 2, 0)) - raises(ValueError, lambda: (lmb(inp_bcast, out=noncontig_broadcast))) - - all_right_broadcast_F = np.empty((len(exprs), 4), order='F') - lmb.order = 'F' - lmb(np.array(np.array(inp_bcast).T), out=all_right_broadcast_F) - - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_broadcast(): - a = np.linspace(-np.pi, np.pi) - inp = np.ascontiguousarray(np.vstack((np.cos(a), np.sin(a))).T) # 50 rows 2 cols - assert inp.flags['C_CONTIGUOUS'] - x, y = se.symbols('x y') - distance = se.Lambdify([x, y], [se.sqrt(x**2 + y**2)]) - assert np.allclose(distance([inp[0, 0], inp[0, 1]]), [1]) - dists = distance(inp) - assert dists.shape == (50, 1) - assert np.allclose(dists, 1) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_broadcast_multiple_extra_dimensions(): - inp = np.arange(12.).reshape((4, 3, 1)) - x = se.symbols('x') - cb = se.Lambdify([x], [x**2, x**3]) - assert np.allclose(cb([inp[0, 2]]), [4, 8]) - out = cb(inp) - assert out.shape == (4, 3, 1, 2) - out = out.squeeze() - assert abs(out[2, 1, 0] - 7**2) < 1e-14 - assert abs(out[2, 1, 1] - 7**3) < 1e-14 - assert abs(out[-1, -1, 0] - 11**2) < 1e-14 - assert abs(out[-1, -1, 1] - 11**3) < 1e-14 - - -def _get_cse_exprs(): - args = x, y = se.symbols('x y') - exprs = [x*x + y, y/(x*x), y*x*x+x] - inp = [11, 13] - ref = [121+13, 13/121, 13*121 + 11] - return args, exprs, inp, ref - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_cse(): - args, exprs, inp, ref = _get_cse_exprs() - lmb = se.Lambdify(args, exprs, cse=True) - out = lmb(inp) - assert allclose(out, ref) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_cse_gh174(): - x = se.symbols('x') - funcs = [se.cos(x)**i for i in range(5)] - f_lmb = se.Lambdify([x], funcs) - f_cse = se.Lambdify([x], funcs, cse=True) - a = np.array([1, 2, 3]) - assert np.allclose(f_lmb(a), f_cse(a)) - - -def _get_cse_exprs_big(): - # this is essentially a performance test (can be replaced by a benchmark) - x, p = se.symarray('x', 14), se.symarray('p', 14) - exp = se.exp - exprs = [ - x[0] + x[1] - x[4] + 36.252574322669, x[0] - x[2] + x[3] + 21.3219379611249, - x[3] + x[5] - x[6] + 9.9011158998744, 2*x[3] + x[5] - x[7] + 18.190422234653, - 3*x[3] + x[5] - x[8] + 24.8679190043357, 4*x[3] + x[5] - x[9] + 29.9336062089226, - -x[10] + 5*x[3] + x[5] + 28.5520551531262, 2*x[0] + x[11] - 2*x[4] - 2*x[5] + 32.4401680272417, - 3*x[1] - x[12] + x[5] + 34.9992934135095, 4*x[1] - x[13] + x[5] + 37.0716199972041, - (p[0] - p[1] + 2*p[10] + 2*p[11] - p[12] - 2*p[13] + p[2] + 2*p[5] + 2*p[6] + 2*p[7] + - 2*p[8] + 2*p[9] - exp(x[0]) + exp(x[1]) - 2*exp(x[10]) - 2*exp(x[11]) + exp(x[12]) + - 2*exp(x[13]) - exp(x[2]) - 2*exp(x[5]) - 2*exp(x[6]) - 2*exp(x[7]) - 2*exp(x[8]) - 2*exp(x[9])), - (-p[0] - p[1] - 15*p[10] - 2*p[11] - 3*p[12] - 4*p[13] - 4*p[2] - 3*p[3] - 2*p[4] - 3*p[6] - - 6*p[7] - 9*p[8] - 12*p[9] + exp(x[0]) + exp(x[1]) + 15*exp(x[10]) + 2*exp(x[11]) + - 3*exp(x[12]) + 4*exp(x[13]) + 4*exp(x[2]) + 3*exp(x[3]) + 2*exp(x[4]) + 3*exp(x[6]) + - 6*exp(x[7]) + 9*exp(x[8]) + 12*exp(x[9])), - (-5*p[10] - p[2] - p[3] - p[6] - 2*p[7] - 3*p[8] - 4*p[9] + 5*exp(x[10]) + exp(x[2]) + exp(x[3]) + - exp(x[6]) + 2*exp(x[7]) + 3*exp(x[8]) + 4*exp(x[9])), - -p[1] - 2*p[11] - 3*p[12] - 4*p[13] - p[4] + exp(x[1]) + 2*exp(x[11]) + 3*exp(x[12]) + 4*exp(x[13]) + exp(x[4]), - (-p[10] - 2*p[11] - p[12] - p[13] - p[5] - p[6] - p[7] - p[8] - p[9] + exp(x[10]) + - 2*exp(x[11]) + exp(x[12]) + exp(x[13]) + exp(x[5]) + exp(x[6]) + exp(x[7]) + exp(x[8]) + exp(x[9])) - ] - return tuple(x) + tuple(p), exprs, np.ones(len(x) + len(p)) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_cse_big(): - args, exprs, inp = _get_cse_exprs_big() - lmb = se.Lambdify(args, exprs, cse=True) - out = lmb(inp) - ref = [expr.xreplace(dict(zip(args, inp))) for expr in exprs] - assert allclose(out, ref) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_broadcast_c(): - n = 3 - inp = np.arange(2*n).reshape((n, 2)) - assert inp.flags['C_CONTIGUOUS'] - lmb, check = _get_2_to_2by2() - A = lmb(inp) - assert A.shape == (3, 2, 2) - for i in range(n): - check(A[i, ...], inp[i, :]) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_broadcast_fortran(): - n = 3 - inp = np.arange(2*n).reshape((n, 2), order='F') - lmb, check = _get_2_to_2by2() - A = lmb(inp) - assert A.shape == (3, 2, 2) - for i in range(n): - check(A[i, ...], inp[i, :]) - - -def _get_1_to_2by3_matrix(Mtx=se.DenseMatrix): - x = se.symbols('x') - args = x, - exprs = Mtx(2, 3, [x+1, x+2, x+3, - 1/x, 1/(x*x), 1/(x**3.0)]) - L = se.Lambdify(args, exprs) - - def check(A, inp): - X, = inp - assert abs(A[0, 0] - (X+1)) < 1e-15 - assert abs(A[0, 1] - (X+2)) < 1e-15 - assert abs(A[0, 2] - (X+3)) < 1e-15 - assert abs(A[1, 0] - (1/X)) < 1e-15 - assert abs(A[1, 1] - (1/(X*X))) < 1e-15 - assert abs(A[1, 2] - (1/(X**3.0))) < 1e-15 - return L, check - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_2dim_Matrix(): - L, check = _get_1_to_2by3_matrix() - inp = [7] - check(L(inp), inp) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -@unittest.skipUnless(have_sympy, "SymPy not installed") -def test_2dim_Matrix__sympy(): - import sympy as sp - L, check = _get_1_to_2by3_matrix(sp.Matrix) - inp = [7] - check(L(inp), inp) - - - -def _test_2dim_Matrix_broadcast(): - L, check = _get_1_to_2by3_matrix() - inp = range(1, 5) - out = L(inp) - for i in range(len(inp)): - check(out[i, ...], (inp[i],)) - - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_2dim_Matrix_broadcast(): - _test_2dim_Matrix_broadcast() - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_2dim_Matrix_broadcast_multiple_extra_dim(): - L, check = _get_1_to_2by3_matrix() - inp = np.arange(1, 4*5*6+1).reshape((4, 5, 6)) - out = L(inp) - assert out.shape == (4, 5, 6, 2, 3) - for i, j, k in itertools.product(range(4), range(5), range(6)): - check(out[i, j, k, ...], (inp[i, j, k],)) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_jacobian(): - x, y = se.symbols('x, y') - args = se.DenseMatrix(2, 1, [x, y]) - v = se.DenseMatrix(2, 1, [x**3 * y, (x+1)*(y+1)]) - jac = v.jacobian(args) - lmb = se.Lambdify(args, jac) - out = np.empty((2, 2)) - inp = X, Y = 7, 11 - lmb(inp, out=out) - assert np.allclose(out, [[3 * X**2 * Y, X**3], - [Y + 1, X + 1]]) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_jacobian__broadcast(): - x, y = se.symbols('x, y') - args = se.DenseMatrix(2, 1, [x, y]) - v = se.DenseMatrix(2, 1, [x**3 * y, (x+1)*(y+1)]) - jac = v.jacobian(args) - lmb = se.Lambdify(args, jac) - out = np.empty((3, 2, 2)) - inp0 = 7, 11 - inp1 = 8, 13 - inp2 = 5, 9 - inp = np.array([inp0, inp1, inp2]) - lmb(inp, out=out) - for idx, (X, Y) in enumerate([inp0, inp1, inp2]): - assert np.allclose(out[idx, ...], [[3 * X**2 * Y, X**3], - [Y + 1, X + 1]]) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_excessive_args(): - x = se.symbols('x') - lmb = se.Lambdify([x], [-x]) - inp = np.ones(2) - out = lmb(inp) - assert np.allclose(inp, [1, 1]) - assert len(out) == 2 # broad casting - assert np.allclose(out, -1) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_excessive_out(): - x = se.symbols('x') - lmb = se.Lambdify([x], [-x]) - inp = np.ones(1) - out = np.ones(2) - _ = lmb(inp, out=out[:inp.size]) - assert np.allclose(inp, [1, 1]) - assert out[0] == -1 - assert out[1] == 1 - - -def all_indices(shape): - return itertools.product(*(range(dim) for dim in shape)) - - -def ravelled(A): - try: - return A.ravel() - except AttributeError: - L = [] - for idx in all_indices(A.memview.shape): - L.append(A[idx]) - return L - - -def _get_2_to_2by2_list(real=True): - args = x, y = se.symbols('x y') - exprs = [[x + y*y, y*y], [x*y*y, se.sqrt(x)+y*y]] - L = se.Lambdify(args, exprs, real=real) - - def check(A, inp): - X, Y = inp - assert A.shape[-2:] == (2, 2) - ref = [X + Y*Y, Y*Y, X*Y*Y, cmath.sqrt(X)+Y*Y] - ravA = ravelled(A) - size = _size(ravA) - for i in range(size//4): - for j in range(4): - assert isclose(ravA[i*4 + j], ref[j]) - return L, check - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_2_to_2by2(): - L, check = _get_2_to_2by2_list() - inp = [13, 17] - A = L(inp) - check(A, inp) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_unsafe_real(): - L, check = _get_2_to_2by2_list() - inp = np.array([13., 17.]) - out = np.empty(4) - L.unsafe_real(inp, out) - check(out.reshape((2, 2)), inp) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_unsafe_complex(): - L, check = _get_2_to_2by2_list(real=False) - assert not L.real - inp = np.array([13+11j, 7+4j], dtype=np.complex128) - out = np.empty(4, dtype=np.complex128) - L.unsafe_complex(inp, out) - check(out.reshape((2, 2)), inp) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_itertools_chain(): - args, exprs, inp, check = _get_array() - L = se.Lambdify(args, exprs) - inp = itertools.chain([inp[0]], (inp[1],), [inp[2]]) - A = L(inp) - check(A) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_complex_1(): - x = se.Symbol('x') - lmb = se.Lambdify([x], [1j + x], real=False) - assert abs(lmb([11+13j])[0] - - (11 + 14j)) < 1e-15 - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_complex_2(): - x = se.Symbol('x') - lmb = se.Lambdify([x], [3 + x - 1j], real=False) - assert abs(lmb([11+13j])[0] - - (14 + 12j)) < 1e-15 - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_more_than_255_args(): - # SymPy's lambdify can handle at most 255 arguments - # this is a proof of concept that this limitation does - # not affect SymEngine's Lambdify class - n = 257 - x = se.symarray('x', n) - p, q, r = 17, 42, 13 - terms = [i*s for i, s in enumerate(x, p)] - exprs = [se.add(*terms), r + x[0], -99] - callback = se.Lambdify(x, exprs) - input_arr = np.arange(q, q + n*n).reshape((n, n)) - out = callback(input_arr) - ref = np.empty((n, 3)) - coeffs = np.arange(p, p + n, dtype=np.int64) - for i in range(n): - ref[i, 0] = coeffs.dot(np.arange(q + n*i, q + n*(i+1), dtype=np.int64)) - ref[i, 1] = q + n*i + r - ref[:, 2] = -99 - assert np.allclose(out, ref) - - -def _Lambdify_heterogeneous_output(Lambdify): - x, y = se.symbols('x, y') - args = se.DenseMatrix(2, 1, [x, y]) - v = se.DenseMatrix(2, 1, [x**3 * y, (x+1)*(y+1)]) - jac = v.jacobian(args) - exprs = [jac, x+y, v, (x+1)*(y+1)] - lmb = Lambdify(args, *exprs) - inp0 = 7, 11 - inp1 = 8, 13 - inp2 = 5, 9 - inp = np.array([inp0, inp1, inp2]) - o_j, o_xpy, o_v, o_xty = lmb(inp) - for idx, (X, Y) in enumerate([inp0, inp1, inp2]): - assert np.allclose(o_j[idx, ...], [[3 * X**2 * Y, X**3], - [Y + 1, X + 1]]) - assert np.allclose(o_xpy[idx, ...], [X+Y]) - assert np.allclose(o_v[idx, ...], [[X**3 * Y], [(X+1)*(Y+1)]]) - assert np.allclose(o_xty[idx, ...], [(X+1)*(Y+1)]) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_heterogeneous_output(): - _Lambdify_heterogeneous_output(se.Lambdify) - - -def _sympy_lambdify_heterogeneous_output(cb, Mtx): - x, y = se.symbols('x, y') - args = Mtx(2, 1, [x, y]) - v = Mtx(2, 1, [x**3 * y, (x+1)*(y+1)]) - jac = v.jacobian(args) - exprs = [jac, x+y, v, (x+1)*(y+1)] - lmb = cb(args, exprs) - inp0 = 7, 11 - inp1 = 8, 13 - inp2 = 5, 9 - for idx, (X, Y) in enumerate([inp0, inp1, inp2]): - o_j, o_xpy, o_v, o_xty = lmb(X, Y) - assert np.allclose(o_j, [[3 * X**2 * Y, X**3], - [Y + 1, X + 1]]) - assert np.allclose(o_xpy, [X+Y]) - assert np.allclose(o_v, [[X**3 * Y], [(X+1)*(Y+1)]]) - assert np.allclose(o_xty, [(X+1)*(Y+1)]) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -@unittest.skipUnless(have_sympy, "SymPy not installed") -def test_lambdify__sympy(): - import sympy as sp - _sympy_lambdify_heterogeneous_output(se.lambdify, se.DenseMatrix) - _sympy_lambdify_heterogeneous_output(sp.lambdify, sp.Matrix) - - -def _test_Lambdify_scalar_vector_matrix(Lambdify): - if not have_numpy: - return - args = x, y = se.symbols('x y') - vec = se.DenseMatrix([x+y, x*y]) - jac = vec.jacobian(se.DenseMatrix(args)) - f = Lambdify(args, x**y, vec, jac) - assert f.n_exprs == 3 - s, v, m = f([2, 3]) - assert s == 2**3 - assert np.allclose(v, [[2+3], [2*3]]) - assert np.allclose(m, [ - [1, 1], - [3, 2] - ]) - - for inp in [[2, 3, 5, 7], np.array([[2, 3], [5, 7]])]: - s2, v2, m2 = f(inp) - assert np.allclose(s2, [2**3, 5**7]) - assert np.allclose(v2, [ - [[2+3], [2*3]], - [[5+7], [5*7]] - ]) - assert np.allclose(m2, [ - [ - [1, 1], - [3, 2] - ], - [ - [1, 1], - [7, 5] - ] - ]) - - -def test_Lambdify_scalar_vector_matrix(): - _test_Lambdify_scalar_vector_matrix(lambda *args: se.Lambdify(*args, backend='lambda')) - if se.have_llvm: - _test_Lambdify_scalar_vector_matrix(lambda *args: se.Lambdify(*args, backend='llvm')) - - -def test_Lambdify_scalar_vector_matrix_cse(): - _test_Lambdify_scalar_vector_matrix(lambda *args: se.Lambdify(*args, backend='lambda', cse=True)) - if se.have_llvm: - _test_Lambdify_scalar_vector_matrix(lambda *args: se.Lambdify(*args, backend='llvm', cse=True)) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_gh174(): - # Tests array broadcasting if the expressions form an N-dimensional array - # of say shape (k, l, m) and it contains 'n' arguments (x1, ... xn), then - # if the user provides a Fortran ordered (column-major) input array of shape - # (n, o, p, q), then the returned array will be of shape (k, l, m, o, p, q) - args = x, y = se.symbols('x y') - nargs = len(args) - vec1 = se.DenseMatrix([x, x**2, x**3]) - assert vec1.shape == (3, 1) - assert np.asarray(vec1).shape == (3, 1) - lmb1 = se.Lambdify([x], vec1) - out1 = lmb1(3) - assert out1.shape == (3, 1) - assert np.all(out1 == [[3], [9], [27]]) - assert lmb1([2, 3]).shape == (2, 3, 1) - lmb1.order = 'F' # change order - out1a = lmb1([2, 3]) - assert out1a.shape == (3, 1, 2) - ref1a_squeeze = [[2, 3], - [4, 9], - [8, 27]] - assert np.all(out1a.squeeze() == ref1a_squeeze) - assert out1a.flags['F_CONTIGUOUS'] - assert not out1a.flags['C_CONTIGUOUS'] - - lmb2c = se.Lambdify(args, vec1, x+y, order='C') - lmb2f = se.Lambdify(args, vec1, x+y, order='F') - for out2a in [lmb2c([2, 3]), lmb2f([2, 3])]: - assert np.all(out2a[0] == [[2], [4], [8]]) - assert out2a[0].ndim == 2 - assert out2a[1] == 5 - assert out2a[1].ndim == 0 - inp2b = np.array([ - [2.0, 3.0], - [1.0, 2.0], - [0.0, 6.0] - ]) - raises(ValueError, lambda: (lmb2c(inp2b.T))) - out2c = lmb2c(inp2b) - out2f = lmb2f(np.asfortranarray(inp2b.T)) - assert out2c[0].shape == (3, 3, 1) - assert out2f[0].shape == (3, 1, 3) - for idx, (_x, _y) in enumerate(inp2b): - assert np.all(out2c[0][idx, ...] == [[_x], [_x**2], [_x**3]]) - - assert np.all(out2c[1] == [5, 3, 6]) - assert np.all(out2f[1] == [5, 3, 6]) - assert out2c[1].shape == (3,) - assert out2f[1].shape == (3,) - - def _mtx3(_x, _y): - return [[_x**row_idx + _y**col_idx for col_idx in range(3)] - for row_idx in range(4)] - mtx3c = np.array(_mtx3(x, y), order='C') - mtx3f = np.array(_mtx3(x, y), order='F') - lmb3c = se.Lambdify([x, y], x*y, mtx3c, vec1, order='C') - lmb3f = se.Lambdify([x, y], x*y, mtx3f, vec1, order='F') - inp3c = np.array([[2., 3], [3, 4], [5, 7], [6, 2], [3, 1]]) - inp3f = np.asfortranarray(inp3c.T) - raises(ValueError, lambda: (lmb3c(inp3c.T))) - out3c = lmb3c(inp3c) - assert out3c[0].shape == (5,) - assert out3c[1].shape == (5, 4, 3) - assert out3c[2].shape == (5, 3, 1) # user can apply numpy.squeeze if they want to. - for a, b in zip(out3c, lmb3c(np.ravel(inp3c))): - assert np.all(a == b) - - out3f = lmb3f(inp3f) - assert out3f[0].shape == (5,) - assert out3f[1].shape == (4, 3, 5) - assert out3f[2].shape == (3, 1, 5) # user can apply numpy.squeeze if they want to. - for a, b in zip(out3f, lmb3f(np.ravel(inp3f, order='F'))): - assert np.all(a == b) - - for idx, (_x, _y) in enumerate(inp3c): - assert out3c[0][idx] == _x*_y - assert out3f[0][idx] == _x*_y - assert np.all(out3c[1][idx, ...] == _mtx3(_x, _y)) - assert np.all(out3f[1][..., idx] == _mtx3(_x, _y)) - assert np.all(out3c[2][idx, ...] == [[_x],[_x**2],[_x**3]]) - assert np.all(out3f[2][..., idx] == [[_x],[_x**2],[_x**3]]) - - -def _get_Ndim_args_exprs_funcs(order): - args = x, y = se.symbols('x y') - - # Higher dimensional inputs - def f_a(index, _x, _y): - a, b, c, d = index - return _x**a + _y**b + (_x+_y)**-d - - nd_exprs_a = np.zeros((3, 5, 1, 4), dtype=object, order=order) - for index in np.ndindex(*nd_exprs_a.shape): - nd_exprs_a[index] = f_a(index, x, y) - - def f_b(index, _x, _y): - a, b, c = index - return b/(_x + _y) - - nd_exprs_b = np.zeros((1, 7, 1), dtype=object, order=order) - for index in np.ndindex(*nd_exprs_b.shape): - nd_exprs_b[index] = f_b(index, x, y) - return args, nd_exprs_a, nd_exprs_b, f_a, f_b - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_Ndimensional_order_C(): - args, nd_exprs_a, nd_exprs_b, f_a, f_b = _get_Ndim_args_exprs_funcs(order='C') - lmb4 = se.Lambdify(args, nd_exprs_a, nd_exprs_b, order='C') - nargs = len(args) - - inp_extra_shape = (3, 5, 4) - inp_shape = inp_extra_shape + (nargs,) - inp4 = np.arange(reduce(mul, inp_shape)*1.0).reshape(inp_shape, order='C') - out4a, out4b = lmb4(inp4) - assert out4a.ndim == 7 - assert out4a.shape == inp_extra_shape + nd_exprs_a.shape - assert out4b.ndim == 6 - assert out4b.shape == inp_extra_shape + nd_exprs_b.shape - raises(ValueError, lambda: (lmb4(inp4.T))) - for b, c, d in np.ndindex(inp_extra_shape): - _x, _y = inp4[b, c, d, :] - for index in np.ndindex(*nd_exprs_a.shape): - assert np.isclose(out4a[(b, c, d) + index], f_a(index, _x, _y)) - for index in np.ndindex(*nd_exprs_b.shape): - assert np.isclose(out4b[(b, c, d) + index], f_b(index, _x, _y)) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_Ndimensional_order_F(): - args, nd_exprs_a, nd_exprs_b, f_a, f_b = _get_Ndim_args_exprs_funcs(order='F') - lmb4 = se.Lambdify(args, nd_exprs_a, nd_exprs_b, order='F') - nargs = len(args) - - inp_extra_shape = (3, 5, 4) - inp_shape = (nargs,)+inp_extra_shape - inp4 = np.arange(reduce(mul, inp_shape)*1.0).reshape(inp_shape, order='F') - out4a, out4b = lmb4(inp4) - assert out4a.ndim == 7 - assert out4a.shape == nd_exprs_a.shape + inp_extra_shape - assert out4b.ndim == 6 - assert out4b.shape == nd_exprs_b.shape + inp_extra_shape - raises(ValueError, lambda: (lmb4(inp4.T))) - for b, c, d in np.ndindex(inp_extra_shape): - _x, _y = inp4[:, b, c, d] - for index in np.ndindex(*nd_exprs_a.shape): - assert np.isclose(out4a[index + (b, c, d)], f_a(index, _x, _y)) - for index in np.ndindex(*nd_exprs_b.shape): - assert np.isclose(out4b[index + (b, c, d)], f_b(index, _x, _y)) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_Lambdify_inp_exceptions(): - args = x, y = se.symbols('x y') - lmb1 = se.Lambdify([x], x**2) - raises(ValueError, lambda: (lmb1([]))) - assert lmb1(4) == 16 - assert np.all(lmb1([4, 2]) == [16, 4]) - - lmb2 = se.Lambdify(args, x**2+y**2) - assert lmb2([2, 3]) == 13 - raises(ValueError, lambda: lmb2([])) - raises(ValueError, lambda: lmb2([2])) - raises(ValueError, lambda: lmb2([2, 3, 4])) - assert np.all(lmb2([2, 3, 4, 5]) == [13, 16+25]) - - def _mtx(_x, _y): - return [ - [_x-_y, _y**2], - [_x+_y, _x**2], - [_x*_y, _x**_y] - ] - - mtx = np.array(_mtx(x, y), order='F') - lmb3 = se.Lambdify(args, mtx, order='F') - inp3a = [2, 3] - assert np.all(lmb3(inp3a) == _mtx(*inp3a)) - inp3b = np.array([2, 3, 4, 5, 3, 2, 1, 5]) - for inp in [inp3b, inp3b.tolist(), inp3b.reshape((2, 4), order='F')]: - out3b = lmb3(inp) - assert out3b.shape == (3, 2, 4) - for i in range(4): - assert np.all(out3b[..., i] == _mtx(*inp3b[2*i:2*(i+1)])) - raises(ValueError, lambda: lmb3(inp3b.reshape((4, 2)))) - raises(ValueError, lambda: lmb3(inp3b.reshape((2, 4)).T)) - - -@unittest.skipUnless(have_scipy, "Scipy not installed") -def test_scipy(): - from scipy import integrate - import numpy as np - args = t, x = se.symbols('t, x') - lmb = se.Lambdify(args, [se.exp(-x*t)/t**5], as_scipy=True) - res = integrate.nquad(lmb, [[1, np.inf], [0, np.inf]]) - assert abs(res[0] - 0.2) < 1e-7 - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_as_ctypes(): - import numpy as np - import ctypes - x, y, z = se.symbols('x, y, z') - l = se.Lambdify([x, y, z], [x+y+z, x*y*z+1]) - addr1, addr2 = l.as_ctypes() - inp = np.array([1,2,3], dtype=np.double) - out = np.array([0, 0], dtype=np.double) - addr1(out.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), inp.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), addr2) - assert np.all(out == [6, 7]) - -@unittest.skipUnless(have_numpy, "Numpy not installed") -@unittest.skipUnless(se.have_llvm, "No LLVM support") -def test_llvm_float(): - import numpy as np - import ctypes - from symengine.lib.symengine_wrapper import LLVMFloat - x, y, z = se.symbols('x, y, z') - l = se.Lambdify([x, y, z], [se.Min(x, y), se.Max(y, z)], dtype=np.float32, backend='llvm') - inp = np.array([1,2,3], dtype=np.float32) - exp_out = np.array([1, 3], dtype=np.float32) - out = l(inp) - assert type(l) == LLVMFloat - assert out.dtype == np.float32 - assert np.allclose(out, exp_out) - -@unittest.skipUnless(have_numpy, "Numpy not installed") -@unittest.skipUnless(se.have_llvm, "No LLVM support") -@unittest.skipUnless(se.have_llvm_long_double, "No LLVM IEEE-80 bit support") -def test_llvm_long_double(): - import numpy as np - import ctypes - from symengine.lib.symengine_wrapper import LLVMLongDouble - x, y, z = se.symbols('x, y, z') - l = se.Lambdify([x, y, z], [2*x, y/z], dtype=np.longdouble, backend='llvm') - inp = np.array([1,2,3], dtype=np.longdouble) - exp_out = np.array([2, 2.0/3.0], dtype=np.longdouble) - out = l(inp) - assert type(l) == LLVMLongDouble - assert out.dtype == np.longdouble - assert np.allclose(out, exp_out) diff --git a/symengine/tests/test_logic.py b/symengine/tests/test_logic.py deleted file mode 100644 index 3d0c3391..00000000 --- a/symengine/tests/test_logic.py +++ /dev/null @@ -1,124 +0,0 @@ -from symengine.test_utilities import raises -from symengine.lib.symengine_wrapper import (true, false, Eq, Ne, Ge, Gt, Le, Lt, Symbol, - I, And, Or, Not, Nand, Nor, Xor, Xnor, Piecewise, - Contains, Interval, FiniteSet, oo, log) - -x = Symbol("x") -y = Symbol("y") -z = Symbol("z") - -def test_relationals(): - assert Eq(0) == true - assert Eq(1) == false - assert Eq(x, x) == true - assert Eq(0, 0) == true - assert Eq(1, 0) == false - assert Ne(0, 0) == false - assert Ne(1, 0) == true - assert Lt(0, 1) == true - assert Lt(1, 0) == false - assert Le(0, 1) == true - assert Le(1, 0) == false - assert Le(0, 0) == true - assert Gt(1, 0) == true - assert Gt(0, 1) == false - assert Ge(1, 0) == true - assert Ge(0, 1) == false - assert Ge(1, 1) == true - assert Eq(I, 2) == false - assert Ne(I, 2) == true - eq = Eq(x, y) - assert eq.func(*eq.args) == eq - ne = Ne(x, y) - assert ne.func(*ne.args) == ne - - -def test_rich_cmp(): - assert (x < y) == Lt(x, y) - assert (x <= y) == Le(x, y) - assert (x > y) == Gt(x, y) - assert (x >= y) == Ge(x, y) - - -def test_And(): - assert And() == true - assert And(True) == true - assert And(False) == false - assert And(True, True ) == true - assert And(True, False) == false - assert And(False, False) == false - assert And(True, True, True) == true - raises(TypeError, lambda: x < y and y < 1) - - -def test_Or(): - assert Or() == false - assert Or(True) == true - assert Or(False) == false - assert Or(True, True ) == true - assert Or(True, False) == true - assert Or(False, False) == false - assert Or(True, False, False) == true - raises(TypeError, lambda: x < y or y < 1) - - -def test_Nor(): - assert Nor() == true - assert Nor(True) == false - assert Nor(False) == true - assert Nor(True, True ) == false - assert Nor(True, False) == false - assert Nor(False, False) == true - assert Nor(True, True, True) == false - - -def test_Nand(): - assert Nand() == false - assert Nand(True) == false - assert Nand(False) == true - assert Nand(True, True) == false - assert Nand(True, False) == true - assert Nand(False, False) == true - assert Nand(True, True, True) == false - - -def test_Not(): - assert Not(True) == false - assert Not(False) == true - - -def test_Xor(): - assert Xor() == false - assert Xor(True) == true - assert Xor(False) == false - assert Xor(True, True ) == false - assert Xor(True, False) == true - assert Xor(False, False) == false - assert Xor(True, False, False) == true - - -def test_Xnor(): - assert Xnor() == true - assert Xnor(True) == false - assert Xnor(False) == true - assert Xnor(True, True ) == true - assert Xnor(True, False) == false - assert Xnor(False, False) == true - assert Xnor(True, False, False) == false - - -def test_Piecewise(): - assert Piecewise((x, x < 1), (0, True)) == Piecewise((x, x < 1), (0, True)) - int1 = Interval(1, 2, True, False) - int2 = Interval(2, 5, True, False) - int3 = Interval(5, 10, True, False) - p = Piecewise((x, Contains(x, int1)), (y, Contains(x, int2)), (x + y, Contains(x, int3))) - q = Piecewise((1, Contains(x, int1)), (0, Contains(x, int2)), (1, Contains(x, int3))) - assert p.diff(x) == q - - -def test_Contains(): - assert Contains(x, FiniteSet(0)) != false - assert Contains(x, Interval(1, 1)) != false - assert Contains(oo, Interval(-oo, oo)) == false - assert Contains(-oo, Interval(-oo, oo)) == false diff --git a/symengine/tests/test_matrices.py b/symengine/tests/test_matrices.py deleted file mode 100644 index 9733e10b..00000000 --- a/symengine/tests/test_matrices.py +++ /dev/null @@ -1,757 +0,0 @@ -from symengine import symbols, init_printing -from symengine.lib.symengine_wrapper import (DenseMatrix, Symbol, Integer, - Rational, function_symbol, I, NonSquareMatrixError, ShapeError, zeros, - ones, eye, ImmutableMatrix) -from symengine.test_utilities import raises -import unittest - - -try: - import numpy as np - have_numpy = True -except ImportError: - have_numpy = False - -try: - import sympy - from sympy.core.cache import clear_cache - import atexit - atexit.register(clear_cache) - have_sympy = True -except ImportError: - have_sympy = False - - -def test_init(): - raises(ValueError, lambda: DenseMatrix(2, 1, [0]*4)) - - -def test_get(): - A = DenseMatrix([[1, 2], [3, 4]]) - - assert A.get(0, 0) == 1 - assert A.get(0, 1) == 2 - assert A.get(1, 1) == 4 - - a = Symbol("a") - b = Symbol("b") - c = Symbol("c") - d = Symbol("d") - A = DenseMatrix(2, 2, [a, b, c, d]) - - assert A.get(0, 0) == a - assert A.get(1, 0) == c - assert A.get(1, 1) == d - - assert A.get(-1, 0) == c - assert A.get(-1, -1) == d - - raises(IndexError, lambda: A.get(2, 0)) - raises(IndexError, lambda: A.get(0, 2)) - raises(IndexError, lambda: A.get(-3, 0)) - - -def test_tolist(): - A = DenseMatrix([2, 3]) - assert A.shape == (2, 1) - assert A.tolist() == [[2], [3]] - - -def test_get_item(): - A = DenseMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) - - assert A[5] == 6 - assert A[-1] == 9 - assert A[2, 2] == 9 - assert A[-2, 2] == 6 - - assert A[1:2, 0] == DenseMatrix(1, 1, [4]) - assert A[1:3, 0] == DenseMatrix(2, 1, [4, 7]) - assert A[1:3, 0] == DenseMatrix(2, 1, [4, 7]) - assert A[1:3, 1:] == DenseMatrix(2, 2, [5, 6, 8, 9]) - assert A[1:3, :1] == DenseMatrix(2, 1, [4, 7]) - assert A[0, 0:] == DenseMatrix(1, 3, [1, 2, 3]) - assert A[2, :] == DenseMatrix(1, 3, [7, 8, 9]) - assert A[:2, -2:] == DenseMatrix(2, 2, [2, 3, 5, 6]) - assert A[1:, :3] == DenseMatrix(2, 3, [4, 5, 6, 7, 8, 9]) - assert A[1:] == [2, 3, 4, 5, 6, 7, 8, 9] - assert A[-2:] == [8, 9] - assert A[[0, 2], 0] == DenseMatrix(2, 1, [1, 7]) - assert A[[0, 2], [0]] == DenseMatrix(2, 1, [1, 7]) - assert A[0, [0, 2]] == DenseMatrix(1, 2, [1, 3]) - assert A[[0], [0, 2]] == DenseMatrix(1, 2, [1, 3]) - - raises(IndexError, lambda: A[-10]) - raises(IndexError, lambda: A[9]) - - raises(IndexError, lambda: A[1:3, 3]) - raises(IndexError, lambda: A[1:3, -4]) - - A = zeros(3, 4) - assert list(A[0, :]) == [0, 0, 0, 0] - assert list(A[:, 0]) == [0, 0, 0] - - A = zeros(4, 3) - assert list(A[:, 0]) == [0, 0, 0, 0] - assert list(A[0, :]) == [0, 0, 0] - - -def test_set_item(): - A = DenseMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) - - A[2] = 7 - A[2, 2] = 8 - A[-2] = 3 - A[-2, -1] = 1 - - assert A == DenseMatrix(3, 3, [1, 2, 7, 4, 5, 1, 7, 3, 8]) - - A[0, :] = [10, 11, 12] - assert A == DenseMatrix(3, 3, [10, 11, 12, 4, 5, 1, 7, 3, 8]) - - A[:, 1] = [13, 14, 15] - assert A == DenseMatrix(3, 3, [10, 13, 12, 4, 14, 1, 7, 15, 8]) - - A[0::2, :] = [[1, 2, 3], [4, 5, 6]] - assert A == DenseMatrix(3, 3, [1, 2, 3, 4, 14, 1, 4, 5, 6]) - - B = DenseMatrix(A) - B[[0, 2], 0] = -1 - assert B == DenseMatrix(3, 3, [-1, 2, 3, 4, 14, 1, -1, 5, 6]) - - B = DenseMatrix(A) - B[[0, 2], 0] = [-1, -2] - assert B == DenseMatrix(3, 3, [-1, 2, 3, 4, 14, 1, -2, 5, 6]) - - B = DenseMatrix(A) - B[[0, 2], 0] = [[-1], [-2]] - assert B == DenseMatrix(3, 3, [-1, 2, 3, 4, 14, 1, -2, 5, 6]) - - B = DenseMatrix(A) - B[[0, 2], [0]] = [-1, -2] - assert B == DenseMatrix(3, 3, [-1, 2, 3, 4, 14, 1, -2, 5, 6]) - - B = DenseMatrix(A) - B[[0, 2], [0]] = [[-1], [-2]] - assert B == DenseMatrix(3, 3, [-1, 2, 3, 4, 14, 1, -2, 5, 6]) - - B = DenseMatrix(A) - B[0, [0, 2]] = [-1, -2] - assert B == DenseMatrix(3, 3, [-1, 2, -2, 4, 14, 1, 4, 5, 6]) - - B = DenseMatrix(A) - B[0, [0, 2]] = -1 - assert B == DenseMatrix(3, 3, [-1, 2, -1, 4, 14, 1, 4, 5, 6]) - - B = DenseMatrix(A) - B[:, [0, 2]] = -1 - assert B == DenseMatrix(3, 3, [-1, 2, -1, -1, 14, -1, -1, 5, -1]) - - B = DenseMatrix(A) - B[[0, 1], [0, 2]] = -1 - assert B == DenseMatrix(3, 3, [-1, 2, -1, -1, 14, -1, 4, 5, 6]) - - A = zeros(3, 4) - B = ones(1, 4) - A[0, :] = B - assert A[0, :] == B - - A = zeros(3, 4) - B = ones(3, 1) - A[:, 0] = B - assert A[:, 0] == B - - -def test_set(): - i7 = Integer(7) - y = Symbol("y") - g = function_symbol("g", y) - c = 2*I + 3 - A = DenseMatrix(2, 2, - [Integer(5), Symbol("x"), - function_symbol("f", Symbol("x")), 1 + I]) - - A.set(0, 0, i7) - assert A.get(0, 0) == i7 - A.set(0, 1, y) - assert A.get(0, 1) == y - A.set(1, 0, g) - assert A.get(1, 0) == g - A.set(1, 1, c) - assert A.get(1, 1) == c - - -def test_det(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - assert A.det() == -2 - - a = Symbol("a") - b = Symbol("b") - c = Symbol("c") - d = Symbol("d") - A = DenseMatrix(2, 2, [a, b, c, d]) - assert A.det() == a*d - b*c - - A = DenseMatrix(3, 2, [1, 2, 3, 4, 5, 6]) - raises(NonSquareMatrixError, lambda: A.det()) - - -def test_inv(): - A = DenseMatrix(2, 2, [1, 0, 0, 1]) - assert A.inv() == A - - A = DenseMatrix(2, 2, [1, 2, 2, 3]) - B = DenseMatrix(2, 2, [-3, 2, 2, -1]) - - assert A.inv('LU') == B - assert A.inv('FFLU') == B - assert A.inv('GJ') == B - - -def test_add_matrix(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - B = DenseMatrix(2, 2, [1, 0, 0, 1]) - - assert A.add_matrix(B) == DenseMatrix(2, 2, [2, 2, 3, 5]) - - a = Symbol("a") - b = Symbol("b") - c = Symbol("c") - d = Symbol("d") - A = DenseMatrix(2, 2, [a + b, a - b, a, b]) - B = DenseMatrix(2, 2, [a - b, a + b, -a, b]) - - assert A.add_matrix(B) == DenseMatrix(2, 2, [2*a, 2*a, 0, 2*b]) - assert A + B == DenseMatrix(2, 2, [2*a, 2*a, 0, 2*b]) - - C = DenseMatrix(1, 2, [a, b]) - raises(ShapeError, lambda: A + C) - - -def test_mul_matrix(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - B = DenseMatrix(2, 2, [1, 0, 0, 1]) - - assert A.mul_matrix(B) == A - - a = Symbol("a") - b = Symbol("b") - c = Symbol("c") - d = Symbol("d") - A = DenseMatrix(2, 2, [a, b, c, d]) - B = DenseMatrix(2, 2, [1, 0, 1, 0]) - - assert A.mul_matrix(B) == DenseMatrix(2, 2, [a + b, 0, c + d, 0]) - assert A * B == DenseMatrix(2, 2, [a + b, 0, c + d, 0]) - assert A @ B == DenseMatrix(2, 2, [a + b, 0, c + d, 0]) - assert (A @ DenseMatrix(2, 1, [0]*2)).shape == (2, 1) - - C = DenseMatrix(2, 3, [1, 2, 3, 2, 3, 4]) - D = DenseMatrix(3, 2, [3, 4, 4, 5, 5, 6]) - - assert C.mul_matrix(D) == DenseMatrix(2, 2, [26, 32, 38, 47]) - - raises(ShapeError, lambda: A*D) - - -def test_multiply_elementwise(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - B = DenseMatrix(2, 2, [1, 0, 0, 1]) - - assert A.multiply_elementwise(B) == DenseMatrix(2, 2, [1, 0, 0, 4]) - - -def test_add_scalar(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - - a = Symbol("a") - assert A.add_scalar(a) == DenseMatrix(2, 2, [1 + a, 2 + a, 3 + a, 4 + a]) - - i5 = Integer(5) - assert A.add_scalar(i5) == DenseMatrix(2, 2, [6, 7, 8, 9]) - raises(TypeError, lambda: A + 5) - raises(TypeError, lambda: 5 + A) - - -def test_mul_scalar(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - - a = Symbol("a") - assert A.mul_scalar(a) == DenseMatrix(2, 2, [a, 2*a, 3*a, 4*a]) - - i5 = Integer(5) - assert A.mul_scalar(i5) == DenseMatrix(2, 2, [5, 10, 15, 20]) - assert A * 5 == DenseMatrix(2, 2, [5, 10, 15, 20]) - assert 5 * A == DenseMatrix(2, 2, [5, 10, 15, 20]) - assert a * A == DenseMatrix(2, 2, [a, 2*a, 3*a, 4*a]) - - -def test_neg_abs(): - A = DenseMatrix(2, 3, [1, 2, 3, 4, 5, 6]) - B = DenseMatrix(2, 3, [-1, -2, -3, -4, -5, -6]) - assert -A == B - - assert A == abs(B) - - -def test_sub(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - B = DenseMatrix(2, 2, [0, -1, -2, -3]) - a = Symbol("a") - assert A - B == DenseMatrix(2, 2, [1, 3, 5, 7]) - - C = DenseMatrix(2, 1, [1, 2]) - raises(ShapeError, lambda: A - C) - raises(TypeError, lambda: A - 5) - raises(TypeError, lambda: 5 - A) - - -def test_div(): - w, x, y, z = symbols("w, x, y, z") - A = DenseMatrix([[w, x], [y, z]]) - B = DenseMatrix([[1, 1], [1, 0]]) - C = DenseMatrix([[x, w - x], [z, y - z]]) - - assert A / 2 == DenseMatrix([[w/2, x/2], [y/2, z/2]]) - assert C * B == A - assert A / B == C - - raises(TypeError, lambda: 2/A) - - -def test_transpose(): - A = DenseMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) - - assert A.transpose() == DenseMatrix(3, 3, [1, 4, 7, 2, 5, 8, 3, 6, 9]) - - A = DenseMatrix(2, 2, [1, 2, 2, 1]) - - assert A.transpose() == A - - -def test_conjugate(): - A = DenseMatrix(2, 2, [1, 2, 3, I]) - assert A.conjugate() == DenseMatrix(2, 2, [1, 2, 3, -I]) - - -def test_conjugate_transpose(): - A = DenseMatrix(2, 2, [1, 2, 3, I]) - assert A.conjugate_transpose() == DenseMatrix(2, 2, [1, 3, 2, -I]) - - -def test_trace(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - assert A.trace() == 5 - - -def test_is_zero_matrix(): - A = DenseMatrix(2, 2, [1, 2, 3, I]) - assert not A.is_zero_matrix - B = DenseMatrix(1, 1, [Symbol('x')]) - assert B.is_zero_matrix is None - C = DenseMatrix(3, 3, [0, 0, 0, 0, 0, 0, 0, 0, 0]) - assert C.is_zero_matrix - - -def test_is_real_matrix(): - A = DenseMatrix(2, 2, [1, 2, 3, I]) - assert not A.is_real_matrix - B = DenseMatrix(1, 1, [Symbol('x')]) - assert B.is_real_matrix is None - C = DenseMatrix(3, 3, [0, 0, 0, 0, 0, 0, 0, 0, 0]) - assert C.is_real_matrix - - -def test_is_diagonal(): - A = DenseMatrix(2, 2, [1, 0, 0, I]) - assert A.is_diagonal - B = DenseMatrix(1, 1, [Symbol('x')]) - assert B.is_diagonal - C = DenseMatrix(3, 3, [0, 0, 0, 0, 0, 0, 0, 2, 0]) - assert not C.is_diagonal - - -def test_is_symmetric(): - A = DenseMatrix(2, 2, [1, 3, 2, I]) - assert not A.is_symmetric - B = DenseMatrix(1, 1, [Symbol('x')]) - assert B.is_symmetric - C = DenseMatrix(3, 3, [0, 0, 0, 0, 0, 0, 0, 2, 0]) - assert not C.is_symmetric - - -def test_is_hermitian(): - A = DenseMatrix(2, 2, [1, 3, 2, I]) - assert not A.is_hermitian - B = DenseMatrix(1, 1, [Symbol('x')]) - assert B.is_hermitian is None - C = DenseMatrix(3, 3, [0, I, 0, 0, 0, 0, 0, 2, 0]) - assert not C.is_hermitian - - -def test_is_weakly_diagonally_dominant(): - A = DenseMatrix(2, 2, [2, 1, 1, 2]) - assert A.is_weakly_diagonally_dominant - C = DenseMatrix(3, 3, [Symbol('x'), 0, 0, 0, 3, 0, 0, 0, 4]) - assert C.is_weakly_diagonally_dominant is None - - -def test_is_strongly_diagonally_dominant(): - A = DenseMatrix(2, 2, [2, 1, 1, 2]) - assert A.is_strongly_diagonally_dominant - C = DenseMatrix(3, 3, [Symbol('x'), 2, 0, 0, 4, 0, 0, 0, 4]) - assert C.is_strongly_diagonally_dominant is None - - -def test_is_positive_definite(): - A = DenseMatrix(2, 2, [2, 1, 1, 2]) - assert A.is_positive_definite - C = DenseMatrix(3, 3, [Symbol('x'), 2, 0, 0, 4, 0, 0, 0, 4]) - assert C.is_positive_definite is None - - -def test_is_negative_definite(): - A = DenseMatrix(2, 2, [-2, -1, -1, -2]) - assert A.is_negative_definite - C = DenseMatrix(3, 3, [Symbol('x'), -2, 0, 0, -4, 0, 0, 0, -4]) - assert C.is_negative_definite is None - - -def test_LU(): - A = DenseMatrix(3, 3, [1, 3, 5, 2, 5, 6, 8, 3, 1]) - L, U = A.LU() - - assert L == DenseMatrix(3, 3, [1, 0, 0, 2, 1, 0, 8, 21, 1]) - assert U == DenseMatrix(3, 3, [1, 3, 5, 0, -1, -4, 0, 0, 45]) - - -def test_LDL(): - A = DenseMatrix(3, 3, [4, 12, -16, 12, 37, -43, -16, -43, 98]) - - L, D = A.LDL() - - assert L == DenseMatrix(3, 3, [1, 0, 0, 3, 1, 0, -4, 5, 1]) - assert D == DenseMatrix(3, 3, [4, 0, 0, 0, 1, 0, 0, 0, 9]) - - -def test_solve(): - A = DenseMatrix(4, 4, [1, 2, 3, 4, 2, 2, 3, 4, 3, 3, 3, 4, 9, 8, 7, 6]) - b = DenseMatrix(4, 1, [10, 11, 13, 30]) - y = DenseMatrix(4, 1, [1, 1, 1, 1]) - - x = A.solve(b, 'LU') - assert x == y - x = A.solve(b, 'FFLU') - assert x == y - x = A.solve(b, 'FFGJ') - assert x == y - - -def test_FFLU(): - A = DenseMatrix(4, 4, [1, 2, 3, 4, 2, 2, 3, 4, 3, 3, 3, 4, 9, 8, 7, 6]) - - L, U = A.FFLU() - assert L == DenseMatrix(4, 4, [1, 0, 0, 0, 2, -2, 0, -0, 3, - -3, 3, 0, 9, -10, 10, -10]) - assert U == DenseMatrix(4, 4, [1, 2, 3, 4, 0, -2, -3, -4, - 0, 0, 3, 4, 0, 0, 0, -10]) - - -def test_FFLDU(): - A = DenseMatrix(3, 3, [1, 2, 3, 5, -3, 2, 6, 2, 1]) - L, D, U = A.FFLDU() - - assert L == DenseMatrix(3, 3, [1, 0, 0, 5, -13, 0, 6, -10, 1]) - assert D == DenseMatrix(3, 3, [1, 0, 0, 0, -13, 0, 0, 0, -13]) - assert U == DenseMatrix(3, 3, [1, 2, 3, 0, -13, -13, 0, 0, 91]) - - -def test_QR(): - A = DenseMatrix(3, 3, [12, -51, 4, 6, 167, -68, -4, 24, -41]) - Q, R = A.QR() - - assert Q == DenseMatrix(3, 3, [Rational(6, 7), Rational(-69, 175), - Rational(-58, 175), Rational(3, 7), - Rational(158, 175), Rational(6, 175), - Rational(-2, 7), Rational(6, 35), - Rational(-33, 35)]) - assert R == DenseMatrix(3, 3, [14, 21, -14, 0, 175, -70, 0, 0, 35]) - - -def test_cholesky(): - A = DenseMatrix(3, 3, [4, 12, -16, 12, 37, -43, -16, -43, 98]) - L = A.cholesky() - - assert L == DenseMatrix(3, 3, [2, 0, 0, 6, 1, 0, -8, 5, 3]) - - -def test_str_repr(): - d = DenseMatrix(3, 2, [1, 2, 3, 4, 5, 6]) - assert str(d) == '[1, 2]\n[3, 4]\n[5, 6]\n' - assert str(d) == repr(d) - - -def test_DenseMatrix_symbols(): - x, y, z = symbols("x y z") - D = DenseMatrix(4, 4, - [1, 0, 1, 0, - 0, z, y, 0, - z, 1, x, 1, - 1, 1, 0, 0]) - assert D.get(1, 2) == y - - -def test_jacobian(): - x, y, z, t = symbols("x y z t") - J_correct = DenseMatrix(4, 4, - [1, 0, 1, 0, - 0, z, y, 0, - z, 1, x, 1, - 1, 1, 0, 0]) - D = DenseMatrix(4, 1, [x+z, y*z, z*x+y+t, x+y]) - x = DenseMatrix(4, 1, [x, y, z, t]) - J = D.jacobian(x) - assert J == J_correct - - -def test_size(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - assert A.size == 4 - - -def test_shape(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - assert A.shape == (2, 2) - - -def test_reshape(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - B = DenseMatrix(4, 1, [1, 2, 3, 4]) - C = A.reshape(4, 1) - assert C == B - assert C != A - - -@unittest.skipIf(not have_numpy, 'requires numpy') -def test_dump_real(): - ref = [1, 2, 3, 4] - A = DenseMatrix(2, 2, ref) - out = np.empty(4) - A.dump_real(out) - assert np.allclose(out, ref) - - - -@unittest.skipIf(not have_numpy, 'requires numpy') -def test_dump_complex(): - ref = [1j, 2j, 3j, 4j] - A = DenseMatrix(2, 2, ref) - out = np.empty(4, dtype=np.complex128) - A.dump_complex(out) - assert np.allclose(out, ref) - - -def test_col_swap(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - B = DenseMatrix(2, 2, [2, 1, 4, 3]) - A.col_swap(0, 1) - assert A == B - - -def test_fill(): - A = zeros(4, 4) - A.fill(1) - B = ones(4, 4) - assert A == B - assert A.rows == B.rows - assert A.cols == B.cols - assert A.shape == B.shape == (4, 4) - - -def test_row_swap(): - A = DenseMatrix(2, 2, [1, 2, 3, 4]) - B = DenseMatrix(2, 2, [3, 4, 1, 2]) - A.row_swap(0, 1) - assert A == B - - -def test_row_col_del(): - e = DenseMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) - raises(IndexError, lambda: e.row_del(5)) - raises(IndexError, lambda: e.row_del(-5)) - raises(IndexError, lambda: e.col_del(5)) - raises(IndexError, lambda: e.col_del(-5)) - - assert e.row_del(-1) == DenseMatrix([[1, 2, 3], [4, 5, 6]]) - assert e.col_del(-1) == DenseMatrix([[1, 2], [4, 5]]) - - e = DenseMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) - assert e.row_del(1) == DenseMatrix([[1, 2, 3], [7, 8, 9]]) - assert e.col_del(1) == DenseMatrix([[1, 3], [7, 9]]) - - -def test_row_join(): - assert eye(3).row_join(DenseMatrix([7, 7, 7])) == \ - DenseMatrix([[1, 0, 0, 7], - [0, 1, 0, 7], - [0, 0, 1, 7]]) - - -def test_col_join(): - assert eye(3).col_join(DenseMatrix([[7, 7, 7]])) == \ - DenseMatrix([[1, 0, 0], - [0, 1, 0], - [0, 0, 1], - [7, 7, 7]]) - - -def test_row_insert(): - M = zeros(3) - V = ones(1, 3) - assert M.row_insert(1, V) == DenseMatrix([[0, 0, 0], - [1, 1, 1], - [0, 0, 0], - [0, 0, 0]]) - - -def test_col_insert(): - M = zeros(3) - V = ones(3, 1) - assert M.col_insert(1, V) == DenseMatrix([[0, 1, 0, 0], - [0, 1, 0, 0], - [0, 1, 0, 0]]) - - -def test_rowmul(): - M = ones(3) - assert M.rowmul(2, 2) == DenseMatrix([[1, 1, 1], - [1, 1, 1], - [2, 2, 2]]) - - -def test_rowadd(): - M = ones(3) - assert M.rowadd(2, 1, 1) == DenseMatrix([[1, 1, 1], - [1, 1, 1], - [2, 2, 2]]) - - -def test_row_col(): - m = DenseMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9]) - assert m.row(0) == DenseMatrix(1, 3, [1, 2, 3]) - assert m.col(0) == DenseMatrix(3, 1, [1, 4, 7]) - - -def test_is_square(): - m = DenseMatrix([[1],[1]]) - m2 = DenseMatrix([[2, 2], [2, 2]]) - assert not m.is_square - assert m2.is_square - - -def test_dot(): - A = DenseMatrix(2, 3, [1, 2, 3, 4, 5, 6]) - B = DenseMatrix(2, 1, [7, 8]) - assert A.dot(B) == DenseMatrix(1, 3, [39, 54, 69]) - assert ones(1, 3).dot(ones(3, 1)) == 3 - - -def test_cross(): - M = DenseMatrix(1, 3, [1, 2, 3]) - V = DenseMatrix(1, 3, [3, 4, 5]) - assert M.cross(V) == DenseMatrix(1, 3, [-2, 4, -2]) - raises(ShapeError, lambda: - DenseMatrix(1, 2, [1, 1]).cross(DenseMatrix(1, 2, [1, 1]))) - - -def test_diff(): - x = symbols("x") - M = DenseMatrix(1, 2, [x**2, x]) - result = M.diff(x) - assert isinstance(result, DenseMatrix) - assert result == DenseMatrix(1, 2, [2*x, 1]) - - -def test_immutablematrix(): - A = ImmutableMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) - assert A.shape == (3, 3) - assert A[1, 2] == 6 - assert A[2, 2] == 9 - - assert A[1, :] == ImmutableMatrix([[4, 5, 6]]) - assert A[:2, :2] == ImmutableMatrix([[1, 2], [4, 5]]) - - with raises(TypeError): - A[2, 2] = 5 - - X = DenseMatrix([[1, 2], [3, 4]]) - assert X.as_immutable() == ImmutableMatrix([[1, 2], [3, 4]]) - - assert X.det() == -2 - - X = ImmutableMatrix(eye(3)) - assert isinstance(X + A, ImmutableMatrix) - assert isinstance(X * A, ImmutableMatrix) - assert isinstance(X * 2, ImmutableMatrix) - assert isinstance(2 * X, ImmutableMatrix) - - X = ImmutableMatrix([[1, 2], [3, 4]]) - Y = ImmutableMatrix([[1], [0]]) - assert type(X.LUsolve(Y)) == ImmutableMatrix - - x = Symbol("x") - X = ImmutableMatrix([[1, 2], [3, 4]]) - Y = ImmutableMatrix([[1, 2], [x, 4]]) - assert Y.subs(x, 3) == X - assert Y.xreplace(x, 3) == X - - X = ImmutableMatrix([[1, 2], [3, 4]]) - Y = ImmutableMatrix([[5], [6]]) - Z = X.row_join(Y) - assert isinstance(Z, ImmutableMatrix) - assert Z == ImmutableMatrix([[1, 2, 5], [3, 4, 6]]) - - X = ImmutableMatrix([[1, 2], [3, 4]]) - Y = ImmutableMatrix([[5, 6]]) - Z = X.col_join(Y) - assert isinstance(Z, ImmutableMatrix) - assert Z == ImmutableMatrix([[1, 2], [3, 4], [5, 6]]) - - # Operations of one immutable and one mutable matrix should give immutable result - X = ImmutableMatrix([1]) - Y = DenseMatrix([1]) - assert type(X + Y) == ImmutableMatrix - assert type(Y + X) == ImmutableMatrix - assert type(X * Y) == ImmutableMatrix - assert type(Y * X) == ImmutableMatrix - - -def test_atoms(): - a = Symbol("a") - b = Symbol("b") - X = DenseMatrix([[a, 2], [b, 4]]) - assert X.atoms(Symbol) == {a, b} - - -def test_LUdecomp(): - testmat = DenseMatrix([[0, 2, 5, 3], - [3, 3, 7, 4], - [8, 4, 0, 2], - [-2, 6, 3, 4]]) - L, U, p = testmat.LUdecomposition() - res = L*U - for orig, new in p: - res.row_swap(orig, new) - assert res - testmat == zeros(4) - -def test_repr_latex(): - testmat = DenseMatrix([[0, 2]]) - init_printing(True) - latex_string = testmat._repr_latex_() - assert isinstance(latex_string, str) - init_printing(False) - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_simplify(): - A = ImmutableMatrix([1]) - assert type(A.simplify()) == type(A) diff --git a/symengine/tests/test_ntheory.py b/symengine/tests/test_ntheory.py deleted file mode 100644 index 68b9a23f..00000000 --- a/symengine/tests/test_ntheory.py +++ /dev/null @@ -1,254 +0,0 @@ -from symengine.test_utilities import raises - -from symengine.lib.symengine_wrapper import (isprime, nextprime, gcd, - lcm, gcd_ext, mod, quotient, quotient_mod, mod_inverse, crt, fibonacci, - fibonacci2, lucas, lucas2, binomial, factorial, divides, factor, - factor_lehman_method, factor_pollard_pm1_method, factor_pollard_rho_method, - prime_factors, prime_factor_multiplicities, Sieve, Sieve_iterator, - bernoulli, primitive_root, primitive_root_list, totient, carmichael, - multiplicative_order, legendre, jacobi, kronecker, nthroot_mod, - nthroot_mod_list, powermod, powermod_list, Integer, sqrt_mod) - - -def test_probab_prime_p(): - s = set(Sieve.generate_primes(1000)) - for n in range(1001): - assert (n in s) == isprime(n) - - -def test_nextprime(): - assert nextprime(-3) == 2 - assert nextprime(5) == 7 - assert nextprime(9) == 11 - - -def test_gcd(): - assert gcd(10, 14) == 2 - assert gcd(-5, 3) == 1 - - -def test_lcm(): - assert lcm(10, 14) == 70 - assert lcm(-5, 3) == 15 - - -def test_gcd_ext(): - (q, r, p) = gcd_ext(6, 9) - assert p == q * 6 + r * 9 - (q, r, p) = gcd_ext(-15, 10) - assert p == q * -15 + r * 10 - (q, r, p) = gcd_ext(2, 3) - assert p == q * 2 + r * 3 - assert p == 1 - (q, r, p) = gcd_ext(10, 12) - assert p == q * 10 + r * 12 - assert p == 2 - (q, r, p) = gcd_ext(100, 2004) - assert p == q * 100 + r * 2004 - assert p == 4 - - -def test_mod(): - assert mod(13, 5) == 3 - assert mod(-4, 7) == 3 - - -def test_mod_error(): - raises(ZeroDivisionError, lambda: mod(2, 0)) - - -def test_quotient(): - assert quotient(13, 5) == 2 - assert quotient(-4, 7) == -1 - - -def test_quotient_error(): - raises(ZeroDivisionError, lambda: quotient(1, 0)) - - -def test_quotient_mod(): - assert quotient_mod(13, 5) == (2, 3) - assert quotient_mod(-4, 7) == (-1, 3) - - -def test_quotient_mod_error(): - raises(ZeroDivisionError, lambda: quotient_mod(1, 0)) - - -def test_mod_inverse(): - mod_inverse(2, 7) == 4 - mod_inverse(0, 3) is None - mod_inverse(4, 6) is None - - -def test_crt(): - assert crt([0, 1, 2, 4], [2, 3, 4, 5]) == 34 - assert crt([3, 5], [6, 21]) is None - - -def test_fibonacci(): - assert fibonacci(0) == 0 - assert fibonacci(5) == 5 - - -def test_fibonacci_error(): - raises(NotImplementedError, lambda: fibonacci(-3)) - - -def test_fibonacci2(): - assert fibonacci2(0) == [0, 1] - assert fibonacci2(5) == [5, 3] - - -def test_fibonacci2_error(): - raises(NotImplementedError, lambda: fibonacci2(-1)) - - -def test_lucas(): - assert lucas(2) == 3 - assert lucas(3) == 4 - - -def test_lucas_error(): - raises(NotImplementedError, lambda: lucas(-1)) - - -def test_lucas2(): - assert lucas2(3) == [4, 3] - assert lucas2(5) == [11, 7] - - -def test_lucas2_error(): - raises(NotImplementedError, lambda: lucas2(-1)) - - -def test_binomial(): - assert binomial(5, 2) == 10 - assert binomial(5, 7) == 0 - assert binomial(-5, 2) == 15 - - -def test_binomial_error(): - raises(ArithmeticError, lambda: binomial(5, -1)) - - -def test_factorial(): - assert factorial(5) == 120 - assert factorial(0) == 1 - - -def test_factorial_error(): - raises(ArithmeticError, lambda: factorial(-1)) - - -def test_divides(): - assert divides(5, 2) is False - assert divides(10, 5) is True - assert divides(0, 0) is True - assert divides(5, 0) is False - - -def test_factor(): - f = factor(102) - assert f is not None and divides(102, f) - assert factor(101) is None - - -def test_prime_factors(): - assert prime_factors(100) == [2, 2, 5, 5] - assert prime_factors(1) == [] - - -def test_prime_factor_multiplicities(): - assert prime_factor_multiplicities(90) == \ - {Integer(2): 1, Integer(3): 2, Integer(5): 1} - assert prime_factor_multiplicities(1) == {} - - -def test_sieve(): - assert Sieve.generate_primes(50) == [2, 3, 5, 7, 11, 13, 17, - 19, 23, 29, 31, 37, 41, 43, 47] - assert len(Sieve.generate_primes(1009)) == 169 - - -def test_sieve_iterator(): - it = Sieve_iterator(101) - assert len([i for i in it]) == 26 - - -def test_primitive_root(): - assert primitive_root(27) in [2, 5, 11, 14, 20, 23] - assert primitive_root(15) is None - - -def test_primitive_root_list(): - assert primitive_root_list(54) == [5, 11, 23, 29, 41, 47] - assert primitive_root_list(12) == [] - - -def test_totient(): - assert totient(1) == 1 - assert totient(-15) == 8 - - -def test_carmichael(): - assert carmichael(8) == 2 - assert carmichael(-21) == 6 - - -def test_multiplicative_order(): - assert multiplicative_order(2, 21) == 6 - assert multiplicative_order(5, 10) is None - - -def test_legendre(): - assert legendre(-1, 5) == 1 - assert legendre(0, 5) == 0 - assert legendre(2, 5) == -1 - - -def test_jacobi(): - assert legendre(-1, 77) == 1 - assert legendre(14, 15) == -1 - - -def test_kronecker(): - assert kronecker(9, 2) == 1 - assert kronecker(-5, -1) == -1 - - -def test_nthroot_mod(): - assert nthroot_mod(12, 5, 77) in [3, 31, 38, 45, 59] - assert nthroot_mod(3, 2, 5) is None - - -def test_sqrt_mod(): - assert sqrt_mod(3, 13) == 9 - assert sqrt_mod(6, 23) == 12 - assert sqrt_mod(345, 690) == 345 - assert sqrt_mod(9, 27, True) == [3, 6, 12, 15, 21, 24] - assert sqrt_mod(9, 81, True) == [3, 24, 30, 51, 57, 78] - assert sqrt_mod(9, 3**5, True) == [3, 78, 84, 159, 165, 240] - assert sqrt_mod(81, 3**4, True) == [0, 9, 18, 27, 36, 45, 54, 63, 72] - assert sqrt_mod(81, 3**5, True) == [9, 18, 36, 45, 63, 72, 90, 99, 117,\ - 126, 144, 153, 171, 180, 198, 207, 225, 234] - assert sqrt_mod(81, 3**6, True) == [9, 72, 90, 153, 171, 234, 252, 315,\ - 333, 396, 414, 477, 495, 558, 576, 639, 657, 720] - assert sqrt_mod(81, 3**7, True) == [9, 234, 252, 477, 495, 720, 738, 963,\ - 981, 1206, 1224, 1449, 1467, 1692, 1710, 1935, 1953, 2178] - - -def test_nthroot_mod_list(): - assert nthroot_mod_list(-4, 4, 65) == [4, 6, 7, 9, 17, 19, 22, 32, - 33, 43, 46, 48, 56, 58, 59, 61] - assert nthroot_mod_list(2, 3, 7) == [] - - -def test_powermod(): - assert powermod(3, 8, 7) == 2 - assert powermod(3, Integer(11)/2, 13) in [3, 10] - - -def test_powermod_list(): - assert powermod_list(15, Integer(1)/6, 21) == [3, 6, 9, 12, 15, 18] - assert powermod_list(2, Integer(5)/2, 11) == [] diff --git a/symengine/tests/test_number.py b/symengine/tests/test_number.py deleted file mode 100644 index 14b20af4..00000000 --- a/symengine/tests/test_number.py +++ /dev/null @@ -1,186 +0,0 @@ -from symengine.test_utilities import raises - -from symengine import Integer, I, S, Symbol, pi, Rational -from symengine.lib.symengine_wrapper import (perfect_power, is_square, integer_nthroot) - - -def test_integer(): - i = Integer(5) - assert str(i) == "5" - assert int(i) == 5 - assert float(i) == 5.0 - assert complex(i) == 5.0 + 0j - assert i.real == i - assert i.imag == S.Zero - - -def test_integer_long(): - py_int = 123434444444444444444 - i = Integer(py_int) - assert str(i) == str(py_int) - assert int(i) == py_int - - -def test_integer_string(): - assert Integer("133") == 133 - - -def test_rational(): - i = Integer(5)/10 - assert str(i) == "1/2" - assert int(i) == 0 - assert float(i) == 0.5 - assert complex(i) == 0.5 + 0j - assert i.real == i - assert i.imag == S.Zero - - -def test_complex(): - i = Integer(5)/10 + I - assert str(i) == "1/2 + I" - assert complex(i) == 0.5 + 1j - assert i.real == Integer(1)/2 - assert i.imag == 1 - - i = 0.5 + I - assert str(i) == "0.5 + 1.0*I" - assert complex(i) == 0.5 + 1j - assert i.real == 0.5 - assert i.imag == 1.0 - - -def test_smallfloat_valid(): - i = Integer(7.5) - assert str(i) == "7" - - -def test_bigfloat_valid(): - i = Integer(13333333333333334.5) - assert str(i) == "13333333333333334" - - -def test_is_conditions(): - i = Integer(-123) - assert not i.is_zero - assert not i.is_positive - assert i.is_negative - assert i.is_nonzero - assert i.is_nonpositive - assert not i.is_nonnegative - assert not i.is_complex - - i = Integer(123) - assert not i.is_zero - assert i.is_positive - assert not i.is_negative - assert i.is_nonzero - assert not i.is_nonpositive - assert i.is_nonnegative - assert not i.is_complex - - i = Integer(0) - assert i.is_zero - assert not i.is_positive - assert not i.is_negative - assert not i.is_nonzero - assert i.is_nonpositive - assert i.is_nonnegative - assert not i.is_complex - - i = Integer(1) + I - assert not i.is_zero - assert not i.is_positive - assert not i.is_negative - assert not i.is_nonzero - assert not i.is_nonpositive - assert not i.is_nonnegative - assert i.is_complex - - assert pi.is_number - - -def test_perfect_power(): - assert perfect_power(1) == True - assert perfect_power(7) == False - assert perfect_power(8) == True - assert perfect_power(9) == True - assert perfect_power(10) == False - assert perfect_power(1024) == True - assert perfect_power(1025) == False - assert perfect_power(6**7) == True - assert perfect_power(-27) == True - assert perfect_power(-64) == True - assert perfect_power(-32) == True - - -def test_perfect_square(): - assert is_square(7) == False - assert is_square(8) == False - assert is_square(9) == True - assert is_square(10) == False - assert perfect_power(49) == True - assert perfect_power(50) == False - - -def test_integer_nthroot(): - assert integer_nthroot(1, 2) == (1, True) - assert integer_nthroot(1, 5) == (1, True) - assert integer_nthroot(2, 1) == (2, True) - assert integer_nthroot(2, 2) == (1, False) - assert integer_nthroot(2, 5) == (1, False) - assert integer_nthroot(4, 2) == (2, True) - assert integer_nthroot(123**25, 25) == (123, True) - assert integer_nthroot(123**25 + 1, 25) == (123, False) - assert integer_nthroot(123**25 - 1, 25) == (122, False) - assert integer_nthroot(1, 1) == (1, True) - assert integer_nthroot(0, 1) == (0, True) - assert integer_nthroot(0, 3) == (0, True) - assert integer_nthroot(10000, 1) == (10000, True) - assert integer_nthroot(4, 2) == (2, True) - assert integer_nthroot(16, 2) == (4, True) - assert integer_nthroot(26, 2) == (5, False) - assert integer_nthroot(1234567**7, 7) == (1234567, True) - assert integer_nthroot(1234567**7 + 1, 7) == (1234567, False) - assert integer_nthroot(1234567**7 - 1, 7) == (1234566, False) - b = 25**1000 - assert integer_nthroot(b, 1000) == (25, True) - assert integer_nthroot(b + 1, 1000) == (25, False) - assert integer_nthroot(b - 1, 1000) == (24, False) - c = 10**400 - c2 = c**2 - assert integer_nthroot(c2, 2) == (c, True) - assert integer_nthroot(c2 + 1, 2) == (c, False) - assert integer_nthroot(c2 - 1, 2) == (c - 1, False) - - -def test_is_zero(): - assert Symbol('x').is_zero is None - - -def test_is_positive(): - assert Rational(1, 2).is_positive - assert not Rational(-2, 3).is_positive - assert Symbol('x').is_positive is None - - -def test_is_negative(): - assert not Rational(1, 2).is_negative - assert Rational(-2, 3).is_negative - assert Symbol('x').is_negative is None - - -def test_is_nonpositive(): - assert not Rational(1, 2).is_nonpositive - assert Rational(-2, 3).is_nonpositive - assert Symbol('x').is_nonpositive is None - - -def test_is_nonnegative(): - assert Rational(1, 2).is_nonnegative - assert not Rational(-2, 3).is_nonnegative - assert Symbol('x').is_nonnegative is None - - -def test_is_real(): - assert Rational(1, 2).is_real - assert Symbol('x').is_real is None diff --git a/symengine/tests/test_pickling.py b/symengine/tests/test_pickling.py deleted file mode 100644 index 5ae64a75..00000000 --- a/symengine/tests/test_pickling.py +++ /dev/null @@ -1,59 +0,0 @@ -from symengine import symbols, sin, sinh, have_numpy, have_llvm, cos, Symbol -from symengine.test_utilities import raises -import pickle -import unittest - - -def test_basic(): - x, y, z = symbols('x y z') - expr = sin(cos(x + y)/z)**2 - s = pickle.dumps(expr) - expr2 = pickle.loads(s) - assert expr == expr2 - - -class MySymbolBase(Symbol): - def __init__(self, name, attr): - super().__init__(name=name) - self.attr = attr - - def __eq__(self, other): - if not isinstance(other, MySymbolBase): - return False - return self.name == other.name and self.attr == other.attr - - -class MySymbol(MySymbolBase): - def __reduce__(self): - return (self.__class__, (self.name, self.attr)) - - -def test_pysymbol(): - a = MySymbol("hello", attr=1) - b = pickle.loads(pickle.dumps(a + 2)) - 2 - try: - assert a == b - finally: - a._unsafe_reset() - b._unsafe_reset() - - a = MySymbolBase("hello", attr=1) - try: - raises(NotImplementedError, lambda: pickle.dumps(a)) - raises(NotImplementedError, lambda: pickle.dumps(a + 2)) - finally: - a._unsafe_reset() - - -@unittest.skipUnless(have_llvm, "No LLVM support") -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_llvm_double(): - import numpy as np - from symengine import Lambdify - args = x, y, z = symbols('x y z') - expr = sin(sinh(x+y) + z) - l = Lambdify(args, expr, cse=True, backend='llvm') - ss = pickle.dumps(l) - ll = pickle.loads(ss) - inp = [1, 2, 3] - assert np.allclose(l(inp), ll(inp)) diff --git a/symengine/tests/test_printing.py b/symengine/tests/test_printing.py deleted file mode 100644 index e0c42816..00000000 --- a/symengine/tests/test_printing.py +++ /dev/null @@ -1,38 +0,0 @@ -from symengine import (ccode, unicode, Symbol, sqrt, Pow, Max, sin, Integer, MutableDenseMatrix) -from symengine.test_utilities import raises -from symengine.printing import CCodePrinter, init_printing - -def test_ccode(): - x = Symbol("x") - y = Symbol("y") - assert ccode(x) == "x" - assert ccode(x**3) == "pow(x, 3)" - assert ccode(x**(y**3)) == "pow(x, pow(y, 3))" - assert ccode(x**-1.0) == "pow(x, -1.0)" - assert ccode(Max(x, x*x)) == "fmax(x, pow(x, 2))" - assert ccode(sin(x)) == "sin(x)" - assert ccode(Integer(67)) == "67" - assert ccode(Integer(-1)) == "-1" - -def test_CCodePrinter(): - x = Symbol("x") - y = Symbol("y") - myprinter = CCodePrinter() - - assert myprinter.doprint(1+x, "bork") == "bork = 1 + x;" - assert myprinter.doprint(1*x) == "x" - assert myprinter.doprint(MutableDenseMatrix(1, 2, [x, y]), "larry") == "larry[0] = x;\nlarry[1] = y;" - raises(TypeError, lambda: myprinter.doprint(sin(x), Integer)) - raises(RuntimeError, lambda: myprinter.doprint(MutableDenseMatrix(1, 2, [x, y]))) - -def test_init_printing(): - x = Symbol("x") - assert x._repr_latex_() is None - init_printing() - assert x._repr_latex_() == '$x$' - - -def test_unicode(): - x = Symbol("x") - y = Integer(2) - assert unicode(x / 2) == "x\n―\n2" diff --git a/symengine/tests/test_sage.py b/symengine/tests/test_sage.py deleted file mode 100644 index e364bd6d..00000000 --- a/symengine/tests/test_sage.py +++ /dev/null @@ -1,175 +0,0 @@ -from symengine import (Integer, symbols, sin, cos, pi, E, I, oo, zoo, - nan, true, false, Add, function_symbol, DenseMatrix, - sympify, log, EulerGamma, Catalan, GoldenRatio) -from symengine.lib.symengine_wrapper import (PyNumber, PyFunction, - sage_module, wrap_sage_function, LambertW, KroneckerDelta, erf, - lowergamma, uppergamma, loggamma, beta, floor, ceiling, conjugate) -import unittest - -try: - import sage.all as sage - have_sage = True -except ImportError: - have_sage = False - -@unittest.skipUnless(have_sage, "Sage not installed") -def test_sage_conversions(): - - x, y = sage.SR.var('x y') - x1, y1 = symbols('x, y') - - # Symbol - assert x1._sage_() == x - assert x1 == sympify(x) - - # Integer - assert Integer(12)._sage_() == sage.Integer(12) - assert Integer(12) == sympify(sage.Integer(12)) - - # Rational - assert (Integer(1) / 2)._sage_() == sage.Integer(1) / 2 - assert Integer(1) / 2 == sympify(sage.Integer(1) / 2) - - # Operators - assert x1 + y == x1 + y1 - assert x1 * y == x1 * y1 - assert x1 ** y == x1 ** y1 - assert x1 - y == x1 - y1 - assert x1 / y == x1 / y1 - - assert x + y1 == x + y - assert x * y1 == x * y - # Doesn't work in Sage 6.1.1ubuntu2 - # assert x ** y1 == x ** y - assert x - y1 == x - y - assert x / y1 == x / y - - # Conversions - assert (x1 + y1)._sage_() == x + y - assert (x1 * y1)._sage_() == x * y - assert (x1 ** y1)._sage_() == x ** y - assert (x1 - y1)._sage_() == x - y - assert (x1 / y1)._sage_() == x / y - - assert x1 + y1 == sympify(x + y) - assert x1 * y1 == sympify(x * y) - assert x1 ** y1 == sympify(x ** y) - assert x1 - y1 == sympify(x - y) - assert x1 / y1 == sympify(x / y) - - # Functions - assert sin(x1) == sin(x) - assert sin(x1)._sage_() == sage.sin(x) - assert sin(x1) == sympify(sage.sin(x)) - - assert cos(x1) == cos(x) - assert cos(x1)._sage_() == sage.cos(x) - assert cos(x1) == sympify(sage.cos(x)) - - assert function_symbol('f', x1, y1)._sage_() == sage.function('f')(x, y) - assert (function_symbol('f', 2 * x1, x1 + y1).diff(x1)._sage_() == - sage.function('f')(2 * x, x + y).diff(x)) - - assert LambertW(x1) == LambertW(x) - assert LambertW(x1)._sage_() == sage.lambert_w(x) - - assert KroneckerDelta(x1, y1) == KroneckerDelta(x, y) - assert KroneckerDelta(x1, y1)._sage_() == sage.kronecker_delta(x, y) - - assert erf(x1) == erf(x) - assert erf(x1)._sage_() == sage.erf(x) - - assert lowergamma(x1, y1) == lowergamma(x, y) - assert lowergamma(x1, y1)._sage_() == sage.gamma_inc_lower(x, y) - - assert uppergamma(x1, y1) == uppergamma(x, y) - assert uppergamma(x1, y1)._sage_() == sage.gamma_inc(x, y) - - assert loggamma(x1) == loggamma(x) - assert loggamma(x1)._sage_() == sage.log_gamma(x) - - assert beta(x1, y1) == beta(x, y) - assert beta(x1, y1)._sage_() == sage.beta(x, y) - - assert floor(x1) == floor(x) - assert floor(x1)._sage_() == sage.floor(x) - - assert ceiling(x1) == ceiling(x) - assert ceiling(x1)._sage_() == sage.ceil(x) - - assert conjugate(x1) == conjugate(x) - assert conjugate(x1)._sage_() == sage.conjugate(x) - - # For the following test, sage needs to be modified - # assert sage.sin(x) == sage.sin(x1) - - # Constants and Booleans - assert pi._sage_() == sage.pi - assert E._sage_() == sage.e - assert I._sage_() == sage.I - assert GoldenRatio._sage_() == sage.golden_ratio - assert Catalan._sage_() == sage.catalan - assert EulerGamma._sage_() == sage.euler_gamma - assert oo._sage_() == sage.oo - assert zoo._sage_() == sage.unsigned_infinity - assert nan._sage_() == sage.NaN - assert true._sage_() == True - assert false._sage_() == False - - assert pi == sympify(sage.pi) - assert E == sympify(sage.e) - assert GoldenRatio == sympify(sage.golden_ratio) - assert Catalan == sympify(sage.catalan) - assert EulerGamma == sympify(sage.euler_gamma) - assert oo == sympify(sage.oo) - assert zoo == sympify(sage.unsigned_infinity) - assert nan == sympify(sage.NaN) - - # SympyConverter does not support converting the following - # assert I == sympify(sage.I) - - # Matrix - assert DenseMatrix(1, 2, [x1, y1])._sage_() == sage.matrix([[x, y]]) - - # SympyConverter does not support converting the following - # assert DenseMatrix(1, 2, [x1, y1]) == sympify(sage.matrix([[x, y]])) - - # Sage Number - a = sage.Mod(2, 7) - b = PyNumber(a, sage_module) - - a = a + 8 - b = b + 8 - assert isinstance(b, PyNumber) - assert b._sage_() == a - assert str(a) == str(b) - - # Sage Function - e = x1 + wrap_sage_function(sage.log_gamma(x)) - assert str(e) == "x + log_gamma(x)" - assert isinstance(e, Add) - assert (e + wrap_sage_function(sage.log_gamma(x)) == - x1 + 2*wrap_sage_function(sage.log_gamma(x))) - - f = e.subs({x1: 10}) - assert f == 10 + log(362880) - - f = e.subs({x1: 2}) - assert f == 2 - - f = e.subs({x1: 100}) - v = f.n(53, real=True) - assert abs(float(v) - 459.13420537) < 1e-7 - - f = e.diff(x1) - # Enable this once symengine conversions are in - # sage as sage.psi is converted to a sympy function in `e.diff(x1)` - # assert f == 1 + wrap_sage_function(sage.psi(x)) - - -# This string contains Sage doctests, that execute all the functions above. -# When you add a new function, add it here as well. -""" -TESTS:: - sage: test_sage_conversions() -""" diff --git a/symengine/tests/test_series_expansion.py b/symengine/tests/test_series_expansion.py deleted file mode 100644 index 651e3630..00000000 --- a/symengine/tests/test_series_expansion.py +++ /dev/null @@ -1,22 +0,0 @@ -from symengine.test_utilities import raises -from symengine.lib.symengine_wrapper import (series, have_piranha, have_flint, - Symbol, Integer, sin, cos, exp, sqrt, E) - - -def test_series_expansion(): - x = Symbol('x') - ex = series(sin(1+x), x, n=10) - assert ex.coeff(x, 7) == -cos(1)/5040 - - x = Symbol('x') - ex = series(1/(1-x), x, n=10) - assert ex.coeff(x, 9) == 1 - ex = series(sin(x)*cos(x), x, n=10) - assert ex.coeff(x, 8) == 0 - assert ex.coeff(x, 9) == Integer(2)/Integer(2835) - - ex = series(E**x, x, n=10) - assert ex.coeff(x, 9) == Integer(1)/Integer(362880) - ex1 = series(1/sqrt(4-x), x, n=50) - ex2 = series((4-x)**(Integer(-1)/Integer(2)), x, n=50) - assert ex1.coeff(x, 49) == ex2.coeff(x, 49) diff --git a/symengine/tests/test_sets.py b/symengine/tests/test_sets.py deleted file mode 100644 index bfa4ecd4..00000000 --- a/symengine/tests/test_sets.py +++ /dev/null @@ -1,118 +0,0 @@ -from symengine.test_utilities import raises -from symengine.lib.symengine_wrapper import (Interval, EmptySet, UniversalSet, - FiniteSet, Union, Complement, ImageSet, ConditionSet, Reals, Rationals, - Integers, And, Or, oo, Symbol, true, Ge, Eq, Gt) - - -def test_Interval(): - assert Interval(0, oo) == Interval(0, oo, False, True) - assert Interval(0, oo) == Interval(0, oo, left_open=False, right_open=True) - assert Interval(-oo, 0) == Interval(-oo, 0, True, False) - assert Interval(-oo, 0) == Interval(-oo, 0, left_open=True, right_open=False) - assert Interval(oo, -oo) == EmptySet() - assert Interval(oo, oo) == EmptySet() - assert Interval(-oo, -oo) == EmptySet() - assert isinstance(Interval(1, 1), FiniteSet) - - assert Interval(1, 0) == EmptySet() - assert Interval(1, 1, False, True) == EmptySet() - assert Interval(1, 1, True, False) == EmptySet() - assert Interval(1, 1, True, True) == EmptySet() - assert Interval(1, 2).union(Interval(2, 3)) == Interval(1, 3) - - assert Interval(-oo, 0).start == -oo - assert Interval(-oo, 0).end == 0 - - -def test_EmptySet(): - E = EmptySet() - assert E.intersection(UniversalSet()) == E - - -def test_UniversalSet(): - U = UniversalSet() - x = Symbol("x") - assert U.union(Interval(2, 4)) == U - assert U.intersection(Interval(2, 4)) == Interval(2, 4) - assert U.contains(0) == true - - -def test_Reals(): - R = Reals() - assert R.union(Interval(2, 4)) == R - assert R.contains(0) == true - - -def test_Rationals(): - Q = Rationals() - assert Q.union(FiniteSet(2, 3)) == Q - assert Q.contains(0) == true - - -def test_Integers(): - Z = Integers() - assert Z.union(FiniteSet(2, 4)) == Z - assert Z.contains(0) == true - - -def test_FiniteSet(): - x = Symbol("x") - A = FiniteSet(1, 2, 3) - B = FiniteSet(3, 4, 5) - AorB = Union(A, B) - AandB = A.intersection(B) - assert AandB == FiniteSet(3) - - assert FiniteSet(EmptySet()) != EmptySet() - assert FiniteSet(FiniteSet(1, 2, 3)) != FiniteSet(1, 2, 3) - - -def test_Union(): - assert Union(Interval(1, 2), Interval(2, 3)) == Interval(1, 3) - assert Union(Interval(1, 2), Interval(2, 3, True)) == Interval(1, 3) - assert Union(Interval(1, 3), Interval(2, 4)) == Interval(1, 4) - assert Union(Interval(1, 2), Interval(1, 3)) == Interval(1, 3) - assert Union(Interval(1, 3), Interval(1, 2)) == Interval(1, 3) - assert Union(Interval(1, 3, False, True), Interval(1, 2)) == \ - Interval(1, 3, False, True) - assert Union(Interval(1, 3), Interval(1, 2, False, True)) == Interval(1, 3) - assert Union(Interval(1, 2, True), Interval(1, 3)) == Interval(1, 3) - assert Union(Interval(1, 2, True), Interval(1, 3, True)) == \ - Interval(1, 3, True) - assert Union(Interval(1, 2, True), Interval(1, 3, True, True)) == \ - Interval(1, 3, True, True) - assert Union(Interval(1, 2, True, True), Interval(1, 3, True)) == \ - Interval(1, 3, True) - assert Union(Interval(1, 3), Interval(2, 3)) == Interval(1, 3) - assert Union(Interval(1, 3, False, True), Interval(2, 3)) == \ - Interval(1, 3) - assert Union(Interval(1, 2, False, True), Interval(2, 3, True)) != \ - Interval(1, 3) - assert Union(Interval(1, 2), EmptySet()) == Interval(1, 2) - assert Union(EmptySet()) == EmptySet() - - -def test_Complement(): - assert Complement(Interval(1, 3), Interval(1, 2)) == Interval(2, 3, True) - assert Complement(FiniteSet(1, 3, 4), FiniteSet(3, 4)) == FiniteSet(1) - assert Complement(Union(Interval(0, 2), - FiniteSet(2, 3, 4)), Interval(1, 3)) == \ - Union(Interval(0, 1, False, True), FiniteSet(4)) - - -def test_ConditionSet(): - x = Symbol("x") - i1 = Interval(-oo, oo) - f1 = FiniteSet(0, 1, 2, 4) - cond1 = Ge(x**2, 9) - assert ConditionSet(x, And(Eq(0, 1), i1.contains(x))) == EmptySet() - assert ConditionSet(x, And(Gt(1, 0), i1.contains(x))) == i1 - assert ConditionSet(x, And(cond1, f1.contains(x))) == FiniteSet(4) - - -def test_ImageSet(): - x = Symbol("x") - i1 = Interval(0, 1) - assert ImageSet(x, x**2, EmptySet()) == EmptySet() - assert ImageSet(x, 1, i1) == FiniteSet(1) - assert ImageSet(x, x, i1) == i1 diff --git a/symengine/tests/test_solve.py b/symengine/tests/test_solve.py deleted file mode 100644 index 675f1a9f..00000000 --- a/symengine/tests/test_solve.py +++ /dev/null @@ -1,25 +0,0 @@ -from symengine.test_utilities import raises -from symengine import (Interval, EmptySet, FiniteSet, I, oo, Eq, Symbol, - linsolve) -from symengine.lib.symengine_wrapper import solve - -def test_solve(): - x = Symbol("x") - reals = Interval(-oo, oo) - - assert solve(1, x, reals) == EmptySet - assert solve(0, x, reals) == reals - assert solve(x + 3, x, reals) == FiniteSet(-3) - assert solve(x + 3, x, Interval(0, oo)) == EmptySet - assert solve(x, x, reals) == FiniteSet(0) - assert solve(x**2 + 1, x) == FiniteSet(-I, I) - assert solve(x**2 - 2*x + 1, x) == FiniteSet(1) - assert solve(Eq(x**3 + 3*x**2 + 3*x, -1), x, reals) == FiniteSet(-1) - assert solve(x**3 - x, x) == FiniteSet(0, 1, -1) - -def test_linsolve(): - x = Symbol("x") - y = Symbol("y") - assert linsolve([x - 2], [x]) == (2,) - assert linsolve([x - 2, y - 3], [x, y]) == (2, 3) - assert linsolve([x + y - 3, x + 2*y - 4], [x, y]) == (2, 1) diff --git a/symengine/tests/test_subs.py b/symengine/tests/test_subs.py deleted file mode 100644 index b346659b..00000000 --- a/symengine/tests/test_subs.py +++ /dev/null @@ -1,82 +0,0 @@ -import unittest - -from symengine.test_utilities import raises -from symengine import Symbol, sin, cos, sqrt, Add, function_symbol, have_numpy, log - - -def test_basic(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - e = x+y+z - assert e.subs({x: y, z: y}) == 3*y - - -def test_sin(): - x = Symbol("x") - y = Symbol("y") - e = sin(x) - assert e.subs({x: y}) == sin(y) - assert e.subs({x: y}) != sin(x) - - e = cos(x) - assert e.subs({x: 0}) == 1 - assert e.subs(x, 0) == 1 - - -def test_subs_exception(): - x = Symbol("x") - expr = sin(log(x)) - raises(RuntimeError, lambda: expr.subs({x: 0})) - - -def test_args(): - x = Symbol("x") - e = cos(x) - raises(TypeError, lambda: e.subs(x, 0, 3)) - - -def test_f(): - x = Symbol("x") - y = Symbol("y") - f = function_symbol("f", x) - g = function_symbol("g", x) - assert f.subs({function_symbol("f", x): function_symbol("g", x)}) == g - assert ((f+g).subs({function_symbol("f", x): function_symbol("g", x)}) == - 2*g) - - e = (f+x)**3 - assert e.subs({f: y}) == (x+y)**3 - e = e.expand() - assert e.subs({f: y}) == ((x+y)**3).expand() - - -def test_msubs(): - x = Symbol("x") - y = Symbol("y") - f = function_symbol("f", x) - assert f.msubs({f: y}) == y - assert f.diff(x).msubs({f: y}) == f.diff(x) - - -def test_xreplace(): - x = Symbol("x") - y = Symbol("y") - f = sin(cos(x)) - assert f.xreplace({x: y}) == sin(cos(y)) - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_float32(): - import numpy as np - x = Symbol("x") - expr = x * 2 - assert expr.subs({x: np.float32(2)}) == 4.0 - - -@unittest.skipUnless(have_numpy, "Numpy not installed") -def test_float16(): - import numpy as np - x = Symbol("x") - expr = x * 2 - assert expr.subs({x: np.float16(2)}) == 4.0 diff --git a/symengine/tests/test_symbol.py b/symengine/tests/test_symbol.py deleted file mode 100644 index 49825914..00000000 --- a/symengine/tests/test_symbol.py +++ /dev/null @@ -1,179 +0,0 @@ -from symengine import Symbol, symbols, symarray, has_symbol, Dummy -from symengine.test_utilities import raises -import unittest -import platform - - -def test_symbol(): - x = Symbol("x") - assert x.name == "x" - assert str(x) == "x" - assert str(x) != "y" - assert repr(x) == str(x) - - -def test_symbols(): - x = Symbol('x') - y = Symbol('y') - z = Symbol('z') - - assert symbols('x') == x - assert symbols('x ') == x - assert symbols(' x ') == x - assert symbols('x,') == (x,) - assert symbols('x, ') == (x,) - assert symbols('x ,') == (x,) - - assert symbols('x , y') == (x, y) - - assert symbols('x,y,z') == (x, y, z) - assert symbols('x y z') == (x, y, z) - - assert symbols('x,y,z,') == (x, y, z) - assert symbols('x y z ') == (x, y, z) - - xyz = Symbol('xyz') - abc = Symbol('abc') - - assert symbols('xyz') == xyz - assert symbols('xyz,') == (xyz,) - assert symbols('xyz,abc') == (xyz, abc) - - assert symbols(('xyz',)) == (xyz,) - assert symbols(('xyz,',)) == ((xyz,),) - assert symbols(('x,y,z,',)) == ((x, y, z),) - assert symbols(('xyz', 'abc')) == (xyz, abc) - assert symbols(('xyz,abc',)) == ((xyz, abc),) - assert symbols(('xyz,abc', 'x,y,z')) == ((xyz, abc), (x, y, z)) - - assert symbols(('x', 'y', 'z')) == (x, y, z) - assert symbols(['x', 'y', 'z']) == [x, y, z] - assert symbols({'x', 'y', 'z'}) == {x, y, z} - - raises(ValueError, lambda: symbols('')) - raises(ValueError, lambda: symbols(',')) - raises(ValueError, lambda: symbols('x,,y,,z')) - raises(ValueError, lambda: symbols(('x', '', 'y', '', 'z'))) - - x0 = Symbol('x0') - x1 = Symbol('x1') - x2 = Symbol('x2') - - y0 = Symbol('y0') - y1 = Symbol('y1') - - assert symbols('x0:0') == () - assert symbols('x0:1') == (x0,) - assert symbols('x0:2') == (x0, x1) - assert symbols('x0:3') == (x0, x1, x2) - - assert symbols('x:0') == () - assert symbols('x:1') == (x0,) - assert symbols('x:2') == (x0, x1) - assert symbols('x:3') == (x0, x1, x2) - - assert symbols('x1:1') == () - assert symbols('x1:2') == (x1,) - assert symbols('x1:3') == (x1, x2) - - assert symbols('x1:3,x,y,z') == (x1, x2, x, y, z) - - assert symbols('x:3,y:2') == (x0, x1, x2, y0, y1) - assert symbols(('x:3', 'y:2')) == ((x0, x1, x2), (y0, y1)) - - a = Symbol('a') - b = Symbol('b') - c = Symbol('c') - d = Symbol('d') - - assert symbols('x:z') == (x, y, z) - assert symbols('a:d,x:z') == (a, b, c, d, x, y, z) - assert symbols(('a:d', 'x:z')) == ((a, b, c, d), (x, y, z)) - - aa = Symbol('aa') - ab = Symbol('ab') - ac = Symbol('ac') - ad = Symbol('ad') - - assert symbols('aa:d') == (aa, ab, ac, ad) - assert symbols('aa:d,x:z') == (aa, ab, ac, ad, x, y, z) - assert symbols(('aa:d', 'x:z')) == ((aa, ab, ac, ad), (x, y, z)) - - def sym(s): - return str(symbols(s)) - assert sym('a0:4') == '(a0, a1, a2, a3)' - assert sym('a2:4,b1:3') == '(a2, a3, b1, b2)' - assert sym('a1(2:4)') == '(a12, a13)' - assert sym('a0:2.0:2') == '(a0.0, a0.1, a1.0, a1.1)' - assert sym('aa:cz') == '(aaz, abz, acz)' - assert sym('aa:c0:2') == '(aa0, aa1, ab0, ab1, ac0, ac1)' - assert sym('aa:ba:b') == '(aaa, aab, aba, abb)' - assert sym('a:3b') == '(a0b, a1b, a2b)' - assert sym('a-1:3b') == '(a-1b, a-2b)' - assert sym(r'a:2\,:2' + chr(0)) == '(a0,0%s, a0,1%s, a1,0%s, a1,1%s)' % ( - (chr(0),)*4) - assert sym('x(:a:3)') == '(x(a0), x(a1), x(a2))' - assert sym('x(:c):1') == '(xa0, xb0, xc0)' - assert sym('x((:a)):3') == '(x(a)0, x(a)1, x(a)2)' - assert sym('x(:a:3') == '(x(a0, x(a1, x(a2)' - assert sym(':2') == '(0, 1)' - assert sym(':b') == '(a, b)' - assert sym(':b:2') == '(a0, a1, b0, b1)' - assert sym(':2:2') == '(00, 01, 10, 11)' - assert sym(':b:b') == '(aa, ab, ba, bb)' - - raises(ValueError, lambda: symbols(':')) - raises(ValueError, lambda: symbols('a:')) - raises(ValueError, lambda: symbols('::')) - raises(ValueError, lambda: symbols('a::')) - raises(ValueError, lambda: symbols(':a:')) - raises(ValueError, lambda: symbols('::a')) - - -def test_symarray(): - try: - import numpy as np - except ImportError: - return - x0, x1, x2 = arr = symarray('x', 3) - assert arr.shape == (3,) - - assert symarray('y', (2, 3)).shape == (2, 3) - - -def test_has_symbol(): - a = Symbol('a') - b = Symbol('b') - c = Symbol('c') - - assert not has_symbol(2, a) - assert not has_symbol(c, a) - assert has_symbol(a+b, b) - - -def test_dummy(): - x1 = Symbol('x') - x2 = Symbol('x') - xdummy1 = Dummy('x') - xdummy2 = Dummy('x') - - assert x1 == x2 - assert x1 != xdummy1 - assert xdummy1 == (xdummy1 + 1) - 1 - assert xdummy1 != xdummy2 - assert Dummy() != Dummy() - assert Dummy('x') != Dummy('x') - -# Cython cdef classes on PyPy has a __dict__ attribute always -# __slots__ on PyPy are useless anyways. https://stackoverflow.com/a/23077685/4768820 -@unittest.skipUnless(platform.python_implementation()=="CPython", "__slots__ are useless on PyPy") -def test_slots(): - x = Dummy('x') - # Verify the successful use of slots. - assert not hasattr(x, "__dict__") - assert not hasattr(x, "__weakref__") - - x1 = Symbol('x') - # Verify the successful use of slots. - assert not hasattr(x, "__dict__") - assert not hasattr(x, "__weakref__") diff --git a/symengine/tests/test_sympify.py b/symengine/tests/test_sympify.py deleted file mode 100644 index 86c59785..00000000 --- a/symengine/tests/test_sympify.py +++ /dev/null @@ -1,63 +0,0 @@ -from symengine.test_utilities import raises - -from symengine import (Symbol, Integer, sympify, SympifyError, true, false, pi, nan, oo, - zoo, E, I, GoldenRatio, Catalan, Rational, sqrt, Eq) -from symengine.lib.symengine_wrapper import _sympify, S, One, polygamma - - -def test_sympify1(): - assert sympify(1) == Integer(1) - assert sympify(2) != Integer(1) - assert sympify(-5) == Integer(-5) - assert sympify(Integer(3)) == Integer(3) - assert sympify(('0', '0')) == (0, 0) - assert sympify(['0', '0']) == [0, 0] - assert sympify("3+5") == Integer(8) - assert true == sympify(True) - assert false == sympify(False) - - -def test_S(): - assert S(0) == Integer(0) - assert S(1) == Integer(1) - assert S(-1) == Integer(-1) - assert S(1) / 2 == Rational(1, 2) - assert S.One is S(1) - assert S.Zero is S(0) - assert S.NegativeOne is S(-1) - assert S.Half is S(1) / 2 - assert S.Pi is pi - assert S.NaN is S(0) / 0 - assert S.Infinity is -oo * -10 - assert S.NegativeInfinity is oo * (-3) - assert S.ComplexInfinity is zoo - assert S.Exp1 is (E + 1 - 1) - assert S.ImaginaryUnit is sqrt(-1) - assert S.GoldenRatio * 2 / 2 is GoldenRatio - assert S.Catalan * 1 is Catalan - assert S.EulerGamma is polygamma(0, 1) * -1 - assert S.true is Eq(2, 2) - assert S.false is Eq(2, 3) - assert S(1) / 0 is zoo - assert S.Pi * 1 is pi - assert type(S.One) == One - - -def test_sympify_error1a(): - class Test: - pass - raises(SympifyError, lambda: sympify(Test())) - - -def test_sympify_error1b(): - assert not _sympify("1***2", raise_error=False) - - -def test_error1(): - # _sympify doesn't parse strings - raises(SympifyError, lambda: _sympify("x")) - - -def test_sympify_pow(): - # https://github.com/symengine/symengine.py/issues/251 - assert sympify('y*pow(x, -1)') == Symbol('y')/Symbol('x') diff --git a/symengine/tests/test_sympy_compat.py b/symengine/tests/test_sympy_compat.py deleted file mode 100644 index 6316d548..00000000 --- a/symengine/tests/test_sympy_compat.py +++ /dev/null @@ -1,200 +0,0 @@ -from symengine.sympy_compat import (Integer, Rational, S, Basic, Add, Mul, - Pow, symbols, Symbol, log, sin, cos, sech, csch, zeros, atan2, nan, Number, Float, - Min, Max, RealDouble, have_mpfr, Abs) -from symengine.test_utilities import raises - - -def test_Integer(): - i = Integer(5) - assert isinstance(i, Integer) - assert isinstance(i, Rational) - assert isinstance(i, Number) - assert isinstance(i, Basic) - assert i.p == 5 - assert i.q == 1 - - -def test_Rational(): - i = S(1)/2 - assert isinstance(i, Rational) - assert isinstance(i, Number) - assert isinstance(i, Basic) - assert i.p == 1 - assert i.q == 2 - x = symbols("x") - assert not isinstance(x, Rational) - assert not isinstance(x, Number) - - -def test_Float(): - A = Float("1.23", precision = 53) - B = Float("1.23") - C = Float(A) - assert A == B == C - assert isinstance(A, Float) - assert isinstance(B, Float) - assert isinstance(C, Float) - assert isinstance(A, RealDouble) - assert isinstance(B, RealDouble) - assert isinstance(C, RealDouble) - raises(ValueError, lambda: Float("1.23", dps = 3, precision = 10)) - raises(ValueError, lambda: Float(A, dps = 3, precision = 16)) - if have_mpfr: - from symengine.sympy_compat import RealMPFR - A = Float("1.23", dps = 16) - B = Float("1.23", precision = 56) - assert A == B - assert isinstance(A, Float) - assert isinstance(B, Float) - assert isinstance(A, RealMPFR) - assert isinstance(B, RealMPFR) - A = Float(C, dps = 16) - assert A == B - assert isinstance(A, Float) - assert isinstance(A, RealMPFR) - A = Float(A, precision = 53) - assert A == C - assert isinstance(A, Float) - assert isinstance(A, RealDouble) - if not have_mpfr: - raises(ValueError, lambda: Float("1.23", precision = 58)) - - -def test_Add(): - x, y = symbols("x y") - i = Add(x, x) - assert isinstance(i, Mul) - i = Add(x, y) - assert isinstance(i, Add) - assert isinstance(i, Basic) - assert i.func(y, x) == i - - -def test_Mul(): - x, y = symbols("x y") - i = Mul(x, x) - assert isinstance(i, Pow) - i = Mul(x, y) - assert isinstance(i, Mul) - assert isinstance(i, Basic) - assert i.func(y, x) == i - - -def test_Pow(): - x = symbols("x") - i = Pow(x, 1) - assert isinstance(i, Symbol) - i = Pow(x, 2) - assert isinstance(i, Pow) - assert isinstance(i, Basic) - assert i.func(x, 2) == i - - -def test_Max(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - assert Max(Integer(6)/3, 1) == 2 - assert Max(-2, 2) == 2 - assert Max(2, 2) == 2 - assert Max(0.2, 0.3) == 0.3 - assert Max(x, x) == x - assert Max(x, y) == Max(y, x) - assert Max(x, y, z) == Max(z, y, x) - assert Max(x, Max(y, z)) == Max(z, y, x) - assert Max(1000, 100, -100, x, y, z) == Max(x, y, z, 1000) - assert Max(cos(x), sin(x)) == Max(sin(x), cos(x)) - - -def test_Min(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - assert Min(Integer(6)/3, 1) == 1 - assert Min(-2, 2) == -2 - assert Min(2, 2) == 2 - assert Min(0.2, 0.3) == 0.2 - assert Min(x, x) == x - assert Min(x, y) == Min(y, x) - assert Min(x, y, z) == Min(z, y, x) - assert Min(x, Min(y, z)) == Min(z, y, x) - assert Min(1000, 100, -100, x, y, z) == Min(x, y, z, -100) - assert Min(cos(x), sin(x)) == Min(cos(x), sin(x)) - - -def test_NaN(): - type(nan)() == nan - - -def test_sin(): - x = symbols("x") - i = sin(0) - assert isinstance(i, Integer) - i = sin(x) - assert isinstance(i, sin) - - -def test_sech(): - x = symbols("x") - i = sech(0) - assert isinstance(i, Integer) - i = sech(x) - assert isinstance(i, sech) - - -def test_csch(): - x = symbols("x") - i = csch(x) - assert isinstance(i, csch) - i = csch(-1) - j = csch(1) - assert i == -j - - -def test_log(): - x, y = symbols("x y") - i = log(x, y) - assert isinstance(i, Mul) - i = log(x) - assert isinstance(i, log) - - -def test_ATan2(): - x, y = symbols("x y") - i = atan2(x, y) - assert isinstance(i, atan2) - i = atan2(0, 1) - assert i == 0 - - -def test_zeros(): - assert zeros(3, c=2).shape == (3, 2) - - -def test_has_functions_module(): - import symengine.sympy_compat as sp - assert sp.functions.sin(0) == 0 - - -def test_subclass_symbol(): - # Subclass of Symbol with an extra attribute - class Wrapper(Symbol): - def __new__(cls, name, extra_attribute): - return Symbol.__new__(cls, name) - - def __init__(self, name, extra_attribute): - super().__init__(name) - self.extra_attribute = extra_attribute - - # Instantiate the subclass - x = Wrapper("x", extra_attribute=3) - assert x.extra_attribute == 3 - two_x = 2 * x - # Check that after arithmetic, same subclass is returned - assert two_x.args[1] is x - del two_x - x._unsafe_reset() - -def test_Abs(): - x = symbols("x") - assert Abs(x) == Abs(-x) diff --git a/symengine/tests/test_sympy_conv.py b/symengine/tests/test_sympy_conv.py deleted file mode 100644 index 5d173dc4..00000000 --- a/symengine/tests/test_sympy_conv.py +++ /dev/null @@ -1,835 +0,0 @@ -from symengine import (Symbol, Integer, sympify, SympifyError, log, - function_symbol, I, E, pi, oo, zoo, nan, true, false, - exp, gamma, have_mpfr, have_mpc, DenseMatrix, sin, cos, tan, cot, - csc, sec, asin, acos, atan, acot, acsc, asec, sinh, cosh, tanh, coth, - asinh, acosh, atanh, acoth, atan2, Add, Mul, Pow, diff, GoldenRatio, - Catalan, EulerGamma, UnevaluatedExpr, RealDouble) -from symengine.lib.symengine_wrapper import (Subs, Derivative, RealMPFR, - ComplexMPC, PyNumber, Function, LambertW, zeta, dirichlet_eta, - KroneckerDelta, LeviCivita, erf, erfc, lowergamma, uppergamma, - loggamma, beta, polygamma, sign, floor, ceiling, conjugate, And, - Or, Not, Xor, Piecewise, Interval, EmptySet, FiniteSet, Contains, - Union, Complement, UniversalSet, Reals, Rationals, Integers) -import unittest - -# Note: We test _sympy_() for SymEngine -> SymPy conversion, as those are -# methods that are implemented in this library. Users can simply use -# sympy.sympify(...). To do this conversion, as this function will call -# our _sympy_() methods under the hood. -# -# For SymPy -> SymEngine, we test symengine.sympify(...) which -# does the conversion. - -try: - import sympy - from sympy.core.cache import clear_cache - import atexit - atexit.register(clear_cache) - have_sympy = True -except ImportError: - have_sympy = False - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv1(): - x = Symbol("x") - assert x._sympy_() == sympy.Symbol("x") - assert x._sympy_() != sympy.Symbol("y") - x = Symbol("y") - assert x._sympy_() != sympy.Symbol("x") - assert x._sympy_() == sympy.Symbol("y") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv1b(): - x = sympy.Symbol("x") - assert sympify(x) == Symbol("x") - assert sympify(x) != Symbol("y") - x = sympy.Symbol("y") - assert sympify(x) != Symbol("x") - assert sympify(x) == Symbol("y") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv2(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - e = x*y - assert e._sympy_() == sympy.Symbol("x")*sympy.Symbol("y") - e = x*y*z - assert e._sympy_() == sympy.Symbol("x")*sympy.Symbol("y")*sympy.Symbol("z") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv2b(): - x = sympy.Symbol("x") - y = sympy.Symbol("y") - z = sympy.Symbol("z") - e = x*y - assert sympify(e) == Symbol("x")*Symbol("y") - e = x*y*z - assert sympify(e) == Symbol("x")*Symbol("y")*Symbol("z") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv3(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - e = x+y - assert e._sympy_() == sympy.Symbol("x")+sympy.Symbol("y") - e = x+y+z - assert e._sympy_() == sympy.Symbol("x")+sympy.Symbol("y")+sympy.Symbol("z") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv3b(): - x = sympy.Symbol("x") - y = sympy.Symbol("y") - z = sympy.Symbol("z") - e = x+y - assert sympify(e) == Symbol("x")+Symbol("y") - e = x+y+z - assert sympify(e) == Symbol("x")+Symbol("y")+Symbol("z") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv4(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - e = x**y - assert e._sympy_() == sympy.Symbol("x")**sympy.Symbol("y") - e = (x+y)**z - assert (e._sympy_() == - (sympy.Symbol("x")+sympy.Symbol("y"))**sympy.Symbol("z")) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv4b(): - x = sympy.Symbol("x") - y = sympy.Symbol("y") - z = sympy.Symbol("z") - e = x**y - assert sympify(e) == Symbol("x")**Symbol("y") - e = (x+y)**z - assert sympify(e) == (Symbol("x")+Symbol("y"))**Symbol("z") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv5(): - x = Integer(5) - y = Integer(6) - assert x._sympy_() == sympy.Integer(5) - assert (x/y)._sympy_() == sympy.Integer(5) / sympy.Integer(6) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv5b(): - x = sympy.Integer(5) - y = sympy.Integer(6) - assert sympify(x) == Integer(5) - assert sympify(x/y) == Integer(5) / Integer(6) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv6(): - x = Symbol("x") - y = Symbol("y") - assert (x/3)._sympy_() == sympy.Symbol("x") / 3 - assert (3*x)._sympy_() == 3*sympy.Symbol("x") - assert (3+x)._sympy_() == 3+sympy.Symbol("x") - assert (3-x)._sympy_() == 3-sympy.Symbol("x") - assert (x/y)._sympy_() == sympy.Symbol("x") / sympy.Symbol("y") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv6b(): - x = sympy.Symbol("x") - y = sympy.Symbol("y") - assert sympify(x/3) == Symbol("x") / 3 - assert sympify(3*x) == 3*Symbol("x") - assert sympify(3+x) == 3+Symbol("x") - assert sympify(3-x) == 3-Symbol("x") - assert sympify(x/y) == Symbol("x") / Symbol("y") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv7(): - x = Symbol("x") - y = Symbol("y") - assert sin(x/3) == sin(sympy.Symbol("x") / 3) - assert cos(x/3) == cos(sympy.Symbol("x") / 3) - assert tan(x/3) == tan(sympy.Symbol("x") / 3) - assert cot(x/3) == cot(sympy.Symbol("x") / 3) - assert csc(x/3) == csc(sympy.Symbol("x") / 3) - assert sec(x/3) == sec(sympy.Symbol("x") / 3) - assert asin(x/3) == asin(sympy.Symbol("x") / 3) - assert acos(x/3) == acos(sympy.Symbol("x") / 3) - assert atan(x/3) == atan(sympy.Symbol("x") / 3) - assert acot(x/3) == acot(sympy.Symbol("x") / 3) - assert acsc(x/3) == acsc(sympy.Symbol("x") / 3) - assert asec(x/3) == asec(sympy.Symbol("x") / 3) - assert atan2(x/3, y) == atan2(sympy.Symbol("x") / 3, sympy.Symbol("y")) - - assert sin(x/3)._sympy_() == sympy.sin(sympy.Symbol("x") / 3) - assert sin(x/3)._sympy_() != sympy.cos(sympy.Symbol("x") / 3) - assert cos(x/3)._sympy_() == sympy.cos(sympy.Symbol("x") / 3) - assert tan(x/3)._sympy_() == sympy.tan(sympy.Symbol("x") / 3) - assert cot(x/3)._sympy_() == sympy.cot(sympy.Symbol("x") / 3) - assert csc(x/3)._sympy_() == sympy.csc(sympy.Symbol("x") / 3) - assert sec(x/3)._sympy_() == sympy.sec(sympy.Symbol("x") / 3) - assert asin(x/3)._sympy_() == sympy.asin(sympy.Symbol("x") / 3) - assert acos(x/3)._sympy_() == sympy.acos(sympy.Symbol("x") / 3) - assert atan(x/3)._sympy_() == sympy.atan(sympy.Symbol("x") / 3) - assert acot(x/3)._sympy_() == sympy.acot(sympy.Symbol("x") / 3) - assert acsc(x/3)._sympy_() == sympy.acsc(sympy.Symbol("x") / 3) - assert asec(x/3)._sympy_() == sympy.asec(sympy.Symbol("x") / 3) - assert atan2(x/3, y)._sympy_() == sympy.atan2(sympy.Symbol("x") / 3, sympy.Symbol("y")) - - assert sympy.sympify(sin(x/3)) == sympy.sin(sympy.Symbol("x") / 3) - assert sympy.sympify(sin(x/3)) != sympy.cos(sympy.Symbol("x") / 3) - assert sympy.sympify(cos(x/3)) == sympy.cos(sympy.Symbol("x") / 3) - assert sympy.sympify(tan(x/3)) == sympy.tan(sympy.Symbol("x") / 3) - assert sympy.sympify(cot(x/3)) == sympy.cot(sympy.Symbol("x") / 3) - assert sympy.sympify(csc(x/3)) == sympy.csc(sympy.Symbol("x") / 3) - assert sympy.sympify(sec(x/3)) == sympy.sec(sympy.Symbol("x") / 3) - assert sympy.sympify(asin(x/3)) == sympy.asin(sympy.Symbol("x") / 3) - assert sympy.sympify(acos(x/3)) == sympy.acos(sympy.Symbol("x") / 3) - assert sympy.sympify(atan(x/3)) == sympy.atan(sympy.Symbol("x") / 3) - assert sympy.sympify(acot(x/3)) == sympy.acot(sympy.Symbol("x") / 3) - assert sympy.sympify(acsc(x/3)) == sympy.acsc(sympy.Symbol("x") / 3) - assert sympy.sympify(asec(x/3)) == sympy.asec(sympy.Symbol("x") / 3) - assert sympy.sympify(atan2(x/3, y)) == sympy.atan2(sympy.Symbol("x") / 3, sympy.Symbol("y")) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv7b(): - x = sympy.Symbol("x") - y = sympy.Symbol("y") - assert sympify(sympy.sin(x/3)) == sin(Symbol("x") / 3) - assert sympify(sympy.sin(x/3)) != cos(Symbol("x") / 3) - assert sympify(sympy.cos(x/3)) == cos(Symbol("x") / 3) - assert sympify(sympy.tan(x/3)) == tan(Symbol("x") / 3) - assert sympify(sympy.cot(x/3)) == cot(Symbol("x") / 3) - assert sympify(sympy.csc(x/3)) == csc(Symbol("x") / 3) - assert sympify(sympy.sec(x/3)) == sec(Symbol("x") / 3) - assert sympify(sympy.asin(x/3)) == asin(Symbol("x") / 3) - assert sympify(sympy.acos(x/3)) == acos(Symbol("x") / 3) - assert sympify(sympy.atan(x/3)) == atan(Symbol("x") / 3) - assert sympify(sympy.acot(x/3)) == acot(Symbol("x") / 3) - assert sympify(sympy.acsc(x/3)) == acsc(Symbol("x") / 3) - assert sympify(sympy.asec(x/3)) == asec(Symbol("x") / 3) - assert sympify(sympy.atan2(x/3, y)) == atan2(Symbol("x") / 3, Symbol("y")) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv8(): - e1 = function_symbol("f", Symbol("x")) - e2 = function_symbol("g", Symbol("x"), Symbol("y")) - assert e1._sympy_() == sympy.Function("f")(sympy.Symbol("x")) - assert e2._sympy_() != sympy.Function("f")(sympy.Symbol("x")) - assert (e2._sympy_() == - sympy.Function("g")(sympy.Symbol("x"), sympy.Symbol("y"))) - - e3 = function_symbol("q", Symbol("t")) - assert e3._sympy_() == sympy.Function("q")(sympy.Symbol("t")) - assert e3._sympy_() != sympy.Function("f")(sympy.Symbol("t")) - assert (e3._sympy_() != - sympy.Function("q")(sympy.Symbol("t"), sympy.Symbol("t"))) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv8b(): - e1 = sympy.Function("f")(sympy.Symbol("x")) - e2 = sympy.Function("g")(sympy.Symbol("x"), sympy.Symbol("y")) - assert sympify(e1) == function_symbol("f", Symbol("x")) - assert sympify(e2) != function_symbol("f", Symbol("x")) - assert sympify(e2) == function_symbol("g", Symbol("x"), Symbol("y")) - - e3 = sympy.Function("q")(sympy.Symbol("t")) - assert sympify(e3) == function_symbol("q", Symbol("t")) - assert sympify(e3) != function_symbol("f", Symbol("t")) - assert sympify(e3) != function_symbol("q", Symbol("t"), Symbol("t")) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv9(): - x = Symbol("x") - y = Symbol("y") - assert (I)._sympy_() == sympy.I - assert (2*I+3)._sympy_() == 2*sympy.I+3 - assert (2*I/5+Integer(3)/5)._sympy_() == 2*sympy.I/5+sympy.S(3)/5 - assert (x*I+3)._sympy_() == sympy.Symbol("x")*sympy.I + 3 - assert (x+I*y)._sympy_() == sympy.Symbol("x") + sympy.I*sympy.Symbol("y") - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv9b(): - x = Symbol("x") - y = Symbol("y") - assert sympify(sympy.I) == I - assert sympify(2*sympy.I+3) == 2*I+3 - assert sympify(2*sympy.I/5+sympy.S(3)/5) == 2*I/5+Integer(3)/5 - assert sympify(sympy.Symbol("x")*sympy.I + 3) == x*I+3 - assert sympify(sympy.Symbol("x") + sympy.I*sympy.Symbol("y")) == x+I*y - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv10(): - A = DenseMatrix(1, 4, [Integer(1), Integer(2), Integer(3), Integer(4)]) - assert (A._sympy_() == sympy.Matrix(1, 4, - [sympy.Integer(1), sympy.Integer(2), - sympy.Integer(3), sympy.Integer(4)])) - - B = DenseMatrix(4, 1, [Symbol("x"), Symbol("y"), Symbol("z"), Symbol("t")]) - assert (B._sympy_() == sympy.Matrix(4, 1, - [sympy.Symbol("x"), sympy.Symbol("y"), - sympy.Symbol("z"), sympy.Symbol("t")]) - ) - - C = DenseMatrix(2, 2, - [Integer(5), Symbol("x"), - function_symbol("f", Symbol("x")), 1 + I]) - - assert (C._sympy_() == - sympy.Matrix([[5, sympy.Symbol("x")], - [sympy.Function("f")(sympy.Symbol("x")), - 1 + sympy.I]])) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv10b(): - A = sympy.Matrix([[sympy.Symbol("x"), sympy.Symbol("y")], - [sympy.Symbol("z"), sympy.Symbol("t")]]) - assert sympify(A) == DenseMatrix(2, 2, [Symbol("x"), Symbol("y"), - Symbol("z"), Symbol("t")]) - - B = sympy.Matrix([[1, 2], [3, 4]]) - assert sympify(B) == DenseMatrix(2, 2, [Integer(1), Integer(2), Integer(3), - Integer(4)]) - - C = sympy.Matrix([[7, sympy.Symbol("y")], - [sympy.Function("g")(sympy.Symbol("z")), 3 + 2*sympy.I]]) - assert sympify(C) == DenseMatrix(2, 2, [Integer(7), Symbol("y"), - function_symbol("g", - Symbol("z")), - 3 + 2*I]) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv11(): - x = sympy.Symbol("x") - y = sympy.Symbol("y") - x1 = Symbol("x") - y1 = Symbol("y") - f = sympy.Function("f") - f1 = Function("f") - - e1 = diff(f(2*x, y), x) - e2 = diff(f1(2*x1, y1), x1) - e3 = diff(f1(2*x1, y1), y1) - - assert sympify(e1) == e2 - assert sympify(e1) != e3 - - assert e2._sympy_() == e1 - assert e3._sympy_() != e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv12(): - x = Symbol("x") - y = Symbol("y") - assert sinh(x/3) == sinh(sympy.Symbol("x") / 3) - assert cosh(x/3) == cosh(sympy.Symbol("x") / 3) - assert tanh(x/3) == tanh(sympy.Symbol("x") / 3) - assert coth(x/3) == coth(sympy.Symbol("x") / 3) - assert asinh(x/3) == asinh(sympy.Symbol("x") / 3) - assert acosh(x/3) == acosh(sympy.Symbol("x") / 3) - assert atanh(x/3) == atanh(sympy.Symbol("x") / 3) - assert acoth(x/3) == acoth(sympy.Symbol("x") / 3) - - assert sinh(x/3)._sympy_() == sympy.sinh(sympy.Symbol("x") / 3) - assert cosh(x/3)._sympy_() == sympy.cosh(sympy.Symbol("x") / 3) - assert tanh(x/3)._sympy_() == sympy.tanh(sympy.Symbol("x") / 3) - assert coth(x/3)._sympy_() == sympy.coth(sympy.Symbol("x") / 3) - assert asinh(x/3)._sympy_() == sympy.asinh(sympy.Symbol("x") / 3) - assert acosh(x/3)._sympy_() == sympy.acosh(sympy.Symbol("x") / 3) - assert atanh(x/3)._sympy_() == sympy.atanh(sympy.Symbol("x") / 3) - assert acoth(x/3)._sympy_() == sympy.acoth(sympy.Symbol("x") / 3) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv12b(): - x = sympy.Symbol("x") - y = sympy.Symbol("y") - assert sympify(sympy.sinh(x/3)) == sinh(Symbol("x") / 3) - assert sympify(sympy.cosh(x/3)) == cosh(Symbol("x") / 3) - assert sympify(sympy.tanh(x/3)) == tanh(Symbol("x") / 3) - assert sympify(sympy.coth(x/3)) == coth(Symbol("x") / 3) - assert sympify(sympy.asinh(x/3)) == asinh(Symbol("x") / 3) - assert sympify(sympy.acosh(x/3)) == acosh(Symbol("x") / 3) - assert sympify(sympy.atanh(x/3)) == atanh(Symbol("x") / 3) - assert sympify(sympy.acoth(x/3)) == acoth(Symbol("x") / 3) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_tuples_lists(): - x = sympy.Symbol("x") - y = sympy.Symbol("y") - z = sympy.Symbol("z") - L = [x, y, z, x*y, z**y] - t = (x, y, z, x*y, z**y) - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - l2 = [x, y, z, x*y, z**y] - t2 = (x, y, z, x*y, z**y) - assert sympify(L) == l2 - assert sympify(t) == t2 - assert sympify(L) != t2 - assert sympify(t) != l2 - - assert L == l2 - assert t == t2 - assert L != t2 - assert t != l2 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_exp(): - x = Symbol("x") - e1 = sympy.exp(sympy.Symbol("x")) - e2 = exp(x) - assert sympify(e1) == e2 - assert e1 == e2._sympy_() - - e1 = sympy.exp(sympy.Symbol("x")).diff(sympy.Symbol("x")) - e2 = exp(x).diff(x) - assert sympify(e1) == e2 - assert e1 == e2._sympy_() - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_gamma(): - x = Symbol("x") - e1 = sympy.gamma(sympy.Symbol("x")) - e2 = gamma(x) - assert sympify(e1) == e2 - assert e1 == e2._sympy_() - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_constants(): - assert sympify(sympy.E) == E - assert sympy.E == E._sympy_() - - assert sympify(sympy.pi) == pi - assert sympy.pi == pi._sympy_() - - assert sympify(sympy.GoldenRatio) == GoldenRatio - assert sympy.GoldenRatio == GoldenRatio._sympy_() - - assert sympify(sympy.Catalan) == Catalan - assert sympy.Catalan == Catalan._sympy_() - - assert sympify(sympy.EulerGamma) == EulerGamma - assert sympy.EulerGamma == EulerGamma._sympy_() - - assert sympify(sympy.oo) == oo - assert sympy.oo == oo._sympy_() - - assert sympify(sympy.zoo) == zoo - assert sympy.zoo == zoo._sympy_() - - assert sympify(sympy.nan) == nan - assert sympy.nan == nan._sympy_() - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_booleans(): - assert sympify(sympy.S.true) == true - assert sympy.S.true == true._sympy_() - - assert sympify(sympy.S.false) == false - assert sympy.S.false == false._sympy_() - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_abs(): - x = Symbol("x") - e1 = abs(sympy.Symbol("x")) - e2 = abs(x) - assert sympify(e1) == e2 - assert e1 == e2._sympy_() - - e1 = abs(2*sympy.Symbol("x")) - e2 = 2*abs(x) - assert sympify(e1) == e2 - assert e1 == e2._sympy_() - - y = Symbol("y") - e1 = abs(sympy.Symbol("y")*sympy.Symbol("x")) - e2 = abs(y*x) - assert sympify(e1) == e2 - assert e1 == e2._sympy_() - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_mpfr(): - if have_mpfr: - a = RealMPFR('100', 100) - b = sympy.Float('100', 29) - assert sympify(b) == a - assert b == a._sympy_() - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_mpc(): - if have_mpc: - a = ComplexMPC('1', '2', 100) - b = sympy.Float(1, 29) + sympy.Float(2, 29) * sympy.I - assert sympify(b) == a - assert b == a._sympy_() - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_log(): - x = Symbol("x") - x1 = sympy.Symbol("x") - - assert log(x) == log(x1) - assert log(x)._sympy_() == sympy.log(x1) - assert sympify(sympy.log(x1)) == log(x) - - y = Symbol("y") - y1 = sympy.Symbol("y") - - assert log(x, y) == log(x, y1) - assert log(x1, y) == log(x1, y1) - assert log(x, y)._sympy_() == sympy.log(x1, y1) - assert sympify(sympy.log(x1, y1)) == log(x, y) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_lambertw(): - x = Symbol("x") - e1 = sympy.LambertW(sympy.Symbol("x")) - e2 = LambertW(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_zeta(): - x = Symbol("x") - y = Symbol("y") - e1 = sympy.zeta(sympy.Symbol("x")) - e2 = zeta(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - e1 = sympy.zeta(sympy.Symbol("x"), sympy.Symbol("y")) - e2 = zeta(x, y) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_dirichlet_eta(): - x = Symbol("x") - e1 = sympy.dirichlet_eta(sympy.Symbol("x")) - e2 = dirichlet_eta(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_kronecker_delta(): - x = Symbol("x") - y = Symbol("y") - e1 = sympy.KroneckerDelta(sympy.Symbol("x"), sympy.Symbol("y")) - e2 = KroneckerDelta(x, y) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_levi_civita(): - x = Symbol("x") - y = Symbol("y") - z = Symbol("z") - e1 = sympy.LeviCivita(sympy.Symbol("x"), sympy.Symbol("y"), sympy.Symbol("z")) - e2 = LeviCivita(x, y, z) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_erf(): - x = Symbol("x") - e1 = sympy.erf(sympy.Symbol("x")) - e2 = erf(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_erfc(): - x = Symbol("x") - e1 = sympy.erfc(sympy.Symbol("x")) - e2 = erfc(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_lowergamma(): - x = Symbol("x") - y = Symbol("y") - e1 = sympy.lowergamma(sympy.Symbol("x"), sympy.Symbol("y")) - e2 = lowergamma(x, y) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_uppergamma(): - x = Symbol("x") - y = Symbol("y") - e1 = sympy.uppergamma(sympy.Symbol("x"), sympy.Symbol("y")) - e2 = uppergamma(x, y) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_loggamma(): - x = Symbol("x") - e1 = sympy.loggamma(sympy.Symbol("x")) - e2 = loggamma(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_beta(): - x = Symbol("x") - y = Symbol("y") - e1 = sympy.beta(sympy.Symbol("y"), sympy.Symbol("x")) - e2 = beta(y, x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_polygamma(): - x = Symbol("x") - y = Symbol("y") - e1 = sympy.polygamma(sympy.Symbol("x"), sympy.Symbol("y")) - e2 = polygamma(x, y) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_sign(): - x = Symbol("x") - e1 = sympy.sign(sympy.Symbol("x")) - e2 = sign(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_floor(): - x = Symbol("x") - e1 = sympy.floor(sympy.Symbol("x")) - e2 = floor(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_ceiling(): - x = Symbol("x") - e1 = sympy.ceiling(sympy.Symbol("x")) - e2 = ceiling(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conjugate(): - x = Symbol("x") - e1 = sympy.conjugate(sympy.Symbol("x")) - e2 = conjugate(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_unevaluated_expr(): - x = Symbol("x") - e1 = sympy.UnevaluatedExpr(sympy.Symbol("x")) - e2 = UnevaluatedExpr(x) - assert sympify(e1) == e2 - assert e2._sympy_() == e1 - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_logic(): - x = true - y = false - x1 = sympy.true - y1 = sympy.false - - assert And(x, y) == And(x1, y1) - assert And(x1, y) == And(x1, y1) - assert And(x, y)._sympy_() == sympy.And(x1, y1) - assert sympify(sympy.And(x1, y1)) == And(x, y) - - assert Or(x, y) == Or(x1, y1) - assert Or(x1, y) == Or(x1, y1) - assert Or(x, y)._sympy_() == sympy.Or(x1, y1) - assert sympify(sympy.Or(x1, y1)) == Or(x, y) - - assert Not(x) == Not(x1) - assert Not(x1) == Not(x1) - assert Not(x)._sympy_() == sympy.Not(x1) - assert sympify(sympy.Not(x1)) == Not(x) - - assert Xor(x, y) == Xor(x1, y1) - assert Xor(x1, y) == Xor(x1, y1) - assert Xor(x, y)._sympy_() == sympy.Xor(x1, y1) - assert sympify(sympy.Xor(x1, y1)) == Xor(x, y) - - x = Symbol("x") - x1 = sympy.Symbol("x") - - assert Piecewise((x, x < 1), (0, True)) == Piecewise((x1, x1 < 1), (0, True)) - assert Piecewise((x, x1 < 1), (0, True)) == Piecewise((x1, x1 < 1), (0, True)) - assert Piecewise((x, x < 1), (0, True))._sympy_() == sympy.Piecewise((x1, x1 < 1), (0, True)) - assert sympify(sympy.Piecewise((x1, x1 < 1), (0, True))) == Piecewise((x, x < 1), (0, True)) - - assert Contains(x, Interval(1, 1)) == Contains(x1, Interval(1, 1)) - assert Contains(x, Interval(1, 1))._sympy_() == sympy.Contains(x1, Interval(1, 1)) - assert sympify(sympy.Contains(x1, Interval(1, 1))) == Contains(x, Interval(1, 1)) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_sets(): - x = Integer(2) - y = Integer(3) - x1 = sympy.Integer(2) - y1 = sympy.Integer(3) - - assert Interval(x, y) == Interval(x1, y1) - assert Interval(x1, y) == Interval(x1, y1) - assert Interval(x, y)._sympy_() == sympy.Interval(x1, y1) - assert sympify(sympy.Interval(x1, y1)) == Interval(x, y) - - assert sympify(sympy.S.EmptySet) == EmptySet() - assert sympy.S.EmptySet == EmptySet()._sympy_() - - assert sympify(sympy.S.UniversalSet) == UniversalSet() - assert sympy.S.UniversalSet == UniversalSet()._sympy_() - - assert sympify(sympy.S.Reals) == Reals() - assert sympy.S.Reals == Reals()._sympy_() - - assert sympify(sympy.S.Rationals) == Rationals() - assert sympy.S.Rationals == Rationals()._sympy_() - - assert sympify(sympy.S.Integers) == Integers() - assert sympy.S.Integers == Integers()._sympy_() - - assert FiniteSet(x, y) == FiniteSet(x1, y1) - assert FiniteSet(x1, y) == FiniteSet(x1, y1) - assert FiniteSet(x, y)._sympy_() == sympy.FiniteSet(x1, y1) - assert sympify(sympy.FiniteSet(x1, y1)) == FiniteSet(x, y) - - x = Interval(1, 2) - y = Interval(2, 3) - x1 = sympy.Interval(1, 2) - y1 = sympy.Interval(2, 3) - - assert Union(x, y) == Union(x1, y1) - assert Union(x1, y) == Union(x1, y1) - assert Union(x, y)._sympy_() == sympy.Union(x1, y1) - assert sympify(sympy.Union(x1, y1)) == Union(x, y) - - assert Complement(x, y) == Complement(x1, y1) - assert Complement(x1, y) == Complement(x1, y1) - assert Complement(x, y)._sympy_() == sympy.Complement(x1, y1) - assert sympify(sympy.Complement(x1, y1)) == Complement(x, y) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_pynumber(): - a = sympy.FF(7)(3) - b = sympify(a) - - assert isinstance(b, PyNumber) - - a = a + 1 - b = b + 1 - assert isinstance(b, PyNumber) - assert b == a # Check equality via SymEngine - assert a == b # Check equality via SymPy - assert str(a) == str(b) - - a = 1 - a - b = 1 - b - assert isinstance(b, PyNumber) - assert b == a # Check equality via SymEngine - assert a == b # Check equality via SymPy - - a = 2 * a - b = 2 * b - assert isinstance(b, PyNumber) - assert b == a # Check equality via SymEngine - assert a == b # Check equality via SymPy - - if sympy.__version__ != '1.2': - a = 2 / a - b = 2 / b - assert isinstance(b, PyNumber) - assert b == a # Check equality via SymEngine - assert a == b # Check equality via SymPy - - x = Symbol("x") - b = x * sympy.FF(7)(3) - assert isinstance(b, Mul) - - b = b / x - assert isinstance(b, PyNumber) - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_construct_dense_matrix(): - # Test for issue #347 - A = sympy.Matrix([[1, 2], [3, 5]]) - B = DenseMatrix(A) - assert B.shape == (2, 2) - assert list(B) == [1, 2, 3, 5] - - -@unittest.skipIf(not have_sympy, "SymPy not installed") -def test_conv_doubles(): - f = 4.347249999999999 - a = sympify(f) - assert isinstance(a, RealDouble) - assert sympify(a._sympy_()) == a - assert float(a) == f - assert float(a._sympy_()) == f - -def test_conv_large_integers(): - a = Integer(10)**10000 - # check that convert to python int does not throw - b = int(a) - # check that convert to sympy int does not throw - if have_sympy: - c = a._sympy_() - d = sympify(c) diff --git a/symengine/tests/test_var.py b/symengine/tests/test_var.py deleted file mode 100644 index d82d4fab..00000000 --- a/symengine/tests/test_var.py +++ /dev/null @@ -1,68 +0,0 @@ -# Tests for var are in their own file, because var pollutes global namespace. - -from symengine import Symbol, var -from symengine.test_utilities import raises -# make z1 with call-depth = 1 - - -def _make_z1(): - var("z1") - -# make z2 with call-depth = 2 - - -def __make_z2(): - var("z2") - - -def _make_z2(): - __make_z2() - - -def test_var(): - var("a") - assert a == Symbol("a") - - var("b bb cc zz _x") - assert b == Symbol("b") - assert bb == Symbol("bb") - assert cc == Symbol("cc") - assert zz == Symbol("zz") - assert _x == Symbol("_x") - - v = var(['d', 'e', 'fg']) - assert d == Symbol('d') - assert e == Symbol('e') - assert fg == Symbol('fg') - - # check return value - assert v == [d, e, fg] - - -def test_var_global_namespace(): - # see if var() really injects into global namespace - raises(NameError, lambda: z1) - _make_z1() - assert z1 == Symbol("z1") - - raises(NameError, lambda: z2) - _make_z2() - assert z2 == Symbol("z2") - - -def test_var_return(): - raises(ValueError, lambda: var('')) - v2 = var('q') - v3 = var('q p') - - assert v2 == Symbol('q') - assert v3 == (Symbol('q'), Symbol('p')) - - -def test_var_accepts_comma(): - v1 = var('x y z') - v2 = var('x,y,z') - v3 = var('x,y z') - - assert v1 == v2 - assert v1 == v3 diff --git a/symengine/utilities.py b/symengine/utilities.py deleted file mode 100644 index a64ea15e..00000000 --- a/symengine/utilities.py +++ /dev/null @@ -1,280 +0,0 @@ -from .lib.symengine_wrapper import Symbol, Basic -from itertools import combinations, permutations, product, product as cartes -import re as _re -import string -import sys - - -_range = _re.compile('([0-9]*:[0-9]+|[a-zA-Z]?:[a-zA-Z])') - - -def symbols(names, **args): - r""" - Transform strings into instances of :class:`Symbol` class. - :func:`symbols` function returns a sequence of symbols with names taken - from ``names`` argument, which can be a comma or whitespace delimited - string, or a sequence of strings:: - >>> from symengine import symbols - >>> x, y, z = symbols('x,y,z') - >>> a, b, c = symbols('a b c') - The type of output is dependent on the properties of input arguments:: - >>> symbols('x') - x - >>> symbols('x,') - (x,) - >>> symbols('x,y') - (x, y) - >>> symbols(('a', 'b', 'c')) - (a, b, c) - >>> symbols(['a', 'b', 'c']) - [a, b, c] - >>> symbols(set(['a', 'b', 'c'])) - set([a, b, c]) - If an iterable container is needed for a single symbol, set the ``seq`` - argument to ``True`` or terminate the symbol name with a comma:: - >>> symbols('x', seq=True) - (x,) - To reduce typing, range syntax is supported to create indexed symbols. - Ranges are indicated by a colon and the type of range is determined by - the character to the right of the colon. If the character is a digit - then all contiguous digits to the left are taken as the nonnegative - starting value (or 0 if there is no digit left of the colon) and all - contiguous digits to the right are taken as 1 greater than the ending - value:: - >>> symbols('x:10') - (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) - >>> symbols('x5:10') - (x5, x6, x7, x8, x9) - >>> symbols('x5(:2)') - (x50, x51) - >>> symbols('x5:10,y:5') - (x5, x6, x7, x8, x9, y0, y1, y2, y3, y4) - >>> symbols(('x5:10', 'y:5')) - ((x5, x6, x7, x8, x9), (y0, y1, y2, y3, y4)) - If the character to the right of the colon is a letter, then the single - letter to the left (or 'a' if there is none) is taken as the start - and all characters in the lexicographic range *through* the letter to - the right are used as the range:: - >>> symbols('x:z') - (x, y, z) - >>> symbols('x:c') # null range - () - >>> symbols('x(:c)') - (xa, xb, xc) - >>> symbols(':c') - (a, b, c) - >>> symbols('a:d, x:z') - (a, b, c, d, x, y, z) - >>> symbols(('a:d', 'x:z')) - ((a, b, c, d), (x, y, z)) - Multiple ranges are supported; contiguous numerical ranges should be - separated by parentheses to disambiguate the ending number of one - range from the starting number of the next:: - >>> symbols('x:2(1:3)') - (x01, x02, x11, x12) - >>> symbols(':3:2') # parsing is from left to right - (00, 01, 10, 11, 20, 21) - Only one pair of parentheses surrounding ranges are removed, so to - include parentheses around ranges, double them. And to include spaces, - commas, or colons, escape them with a backslash:: - >>> symbols('x((a:b))') - (x(a), x(b)) - >>> symbols('x(:1\,:2)') # or 'x((:1)\,(:2))' - (x(0,0), x(0,1)) - """ - result = [] - - if isinstance(names, str): - marker = 0 - literals = [r'\,', r'\:', r'\ '] - for i in range(len(literals)): - lit = literals.pop(0) - if lit in names: - while chr(marker) in names: - marker += 1 - lit_char = chr(marker) - marker += 1 - names = names.replace(lit, lit_char) - literals.append((lit_char, lit[1:])) - - def literal(s): - if literals: - for c, l in literals: - s = s.replace(c, l) - return s - - names = names.strip() - as_seq = names.endswith(',') - if as_seq: - names = names[:-1].rstrip() - if not names: - raise ValueError('no symbols given') - - # split on commas - names = [n.strip() for n in names.split(',')] - if not all(n for n in names): - raise ValueError('missing symbol between commas') - # split on spaces - for i in range(len(names) - 1, -1, -1): - names[i: i + 1] = names[i].split() - - cls = args.pop('cls', Symbol) - seq = args.pop('seq', as_seq) - - for name in names: - if not name: - raise ValueError('missing symbol') - - if ':' not in name: - symbol = cls(literal(name), **args) - result.append(symbol) - continue - - split = _range.split(name) - # remove 1 layer of bounding parentheses around ranges - for i in range(len(split) - 1): - if i and ':' in split[i] and split[i] != ':' and \ - split[i - 1].endswith('(') and \ - split[i + 1].startswith(')'): - split[i - 1] = split[i - 1][:-1] - split[i + 1] = split[i + 1][1:] - for i, s in enumerate(split): - if ':' in s: - if s[-1].endswith(':'): - raise ValueError('missing end range') - a, b = s.split(':') - if b[-1] in string.digits: - a = 0 if not a else int(a) - b = int(b) - split[i] = [str(c) for c in range(a, b)] - else: - a = a or 'a' - split[i] = [string.ascii_letters[c] for c in range( - string.ascii_letters.index(a), - string.ascii_letters.index(b) + 1)] # inclusive - if not split[i]: - break - else: - split[i] = [s] - else: - seq = True - if len(split) == 1: - names = split[0] - else: - names = [''.join(s) for s in cartes(*split)] - if literals: - result.extend([cls(literal(s), **args) for s in names]) - else: - result.extend([cls(s, **args) for s in names]) - - if not seq and len(result) <= 1: - if not result: - return () - return result[0] - - return tuple(result) - else: - for name in names: - result.append(symbols(name, **args)) - - return type(names)(result) - - -def var(names, **args): - """ - Create symbols and inject them into the global namespace. - - INPUT: -- s -- a string, either a single variable name, or -- a space separated list of variable names, or -- a list of variable names. - - This calls :func:`symbols` with the same arguments and puts the results - into the *global* namespace. It's recommended not to use :func:`var` in - library code, where :func:`symbols` has to be used:: - - Examples - ======== - - >>> from symengine import var - - >>> var('x') - x - >>> x - x - - >>> var('a,ab,abc') - (a, ab, abc) - >>> abc - abc - - See :func:`symbols` documentation for more details on what kinds of - arguments can be passed to :func:`var`. - - """ - def traverse(symbols, frame): - """Recursively inject symbols to the global namespace. """ - for symbol in symbols: - if isinstance(symbol, Basic): - frame.f_globals[symbol.__str__()] = symbol - # Once we hace an undefined function class - # implemented, put a check for function here - else: - traverse(symbol, frame) - - from inspect import currentframe - frame = currentframe().f_back - - try: - syms = symbols(names, **args) - - if syms is not None: - if isinstance(syms, Basic): - frame.f_globals[syms.__str__()] = syms - # Once we hace an undefined function class - # implemented, put a check for function here - else: - traverse(syms, frame) - finally: - del frame # break cyclic dependencies as stated in inspect docs - - return syms - - -class NotIterable: - """ - Use this as mixin when creating a class which is not supposed to return - true when iterable() is called on its instances. I.e. avoid infinite loop - when calling e.g. list() on the instance - """ - pass - - -def iterable(i, exclude=(str, dict, NotIterable)): - """ - Return a boolean indicating whether ``i`` is SymPy iterable. - True also indicates that the iterator is finite, i.e. you e.g. - call list(...) on the instance. - - When SymPy is working with iterables, it is almost always assuming - that the iterable is not a string or a mapping, so those are excluded - by default. If you want a pure Python definition, make exclude=None. To - exclude multiple items, pass them as a tuple. - """ - try: - iter(i) - except TypeError: - return False - if exclude: - return not isinstance(i, exclude) - return True - - -def is_sequence(i): - """ - Return a boolean indicating whether ``i`` is a sequence in the SymPy - sense. If anything that fails the test below should be included as - being a sequence for your application, set 'include' to that object's - type; multiple types should be passed as a tuple of types. - """ - return hasattr(i, '__getitem__') and iterable(i) diff --git a/symengine_version.txt b/symengine_version.txt deleted file mode 100644 index e49372be..00000000 --- a/symengine_version.txt +++ /dev/null @@ -1 +0,0 @@ -c9510fb4b5c30b84adb993573a51f2a9a38a4cfe