While modeling a rat’s neuron axon, I needed to do some symbolic computation. I first used sympy. It failed to return any solution. I tried playing with its option but I did not pursue it too much.
Then, I went to wolfram alpha and pasted my equation there. Click me to see answer.
Then I thought of using GiNaC library of C++. It was some work but I managed to write a small program. This program is available here. The file
axon.cpp is the main file and
compartment.cpp is the file which creates this equation. Run
./run.sh to compile and run the program. It is a
cmake based project.
To my surprise, GiNaC failed to compute a solution.
./run.sh -- Configuring done -- Generating done -- Build files have been written to: /home/dilawar/Work/GITHUB/courses/NeuroCourse/Assignments/Second/Problem01/cpp Scanning dependencies of target Axon [100%] Building CXX object CMakeFiles/Axon.dir/axon.cpp.o Linking CXX executable Axon [100%] Built target Axon And the equation is (0.015915494309189535082+(3.1830988618379066628)*r)^(-1)*(3.5014087480216975145E-4-(0.12095775674984045018)*r) Puting wolfram answer back -4.2814382506543584682E-4 terminate called after throwing an instance of 'GiNaC::pole_error' what(): power::eval(): division by zero ./run.sh: line 2: 24873 Aborted (core dumped) ./Axon
This line in output computes the expression by putting the wolfram answer. Ideally it should be zero but it is not the case.
Puting wolfram answer back -4.2814382506543584682E-4
When I change this value and compute the expression again, I see large changes in output i.e. the function changes rapidly around its solution. I am not sure what I am doing wrong with this library. If everything is fine with my program, then capabilities of this library are rather limited and I’d recommend not using it for any serious lab work.