Ask Your Question

louisgag's profile - activity

2021-03-09 12:16:33 +0100 asked a question definite integral returns error but indefinite followed by equivalent subtraction does not

definite integral returns error but indefinite followed by equivalent subtraction does not Searching the other questions

2021-03-05 14:01:26 +0100 received badge  Commentator
2021-03-05 14:01:26 +0100 commented answer file with extension sws

excellent solution, thank you

2021-02-04 22:30:19 +0100 received badge  Famous Question (source)
2020-03-06 18:50:27 +0100 received badge  Notable Question (source)
2018-05-21 14:11:33 +0100 received badge  Popular Question (source)
2018-01-10 11:48:16 +0100 received badge  Necromancer (source)
2017-02-15 12:13:49 +0100 answered a question Export to C code

Just to add to the list of answers, I'm linking a post I've made which shows how to expand Benjamin Jones' solution to a system of functions and their gradients: http://louisgagnon.com/scBlog/sageCpp...

2017-02-02 12:12:39 +0100 received badge  Editor (source)
2017-02-02 12:07:08 +0100 answered a question How can I print equations just like latex?

I've created an extended version of the script given by Thorsten and posted it on GitHub. This way I will keep it updated were I to make changes or receive suggestions: sageToLatex.sage

LATEX PACKAGES REQUIRED:

*) add the following two lines to the header of you main Latex file if theses packages are not already declared:

\usepackage{esdiff} % for non-italic derivatives

\usepackage{breqn} % automatic linebreaks for eqns

INSTRUCTIONS:

1) paste the whole sageToLatex.sage file somewhere near the beginning of your worksheet and uncomment the following line to set the boolean printArticle as such:

printArticle = bool(1) # enable if want to print the text and equations for the article

2) in your document, include, where desired, the following string additions:

if (printArticle):
   latexPrint += 'YOUR TEXT,' + get_expression('derivative(x/b + 5 + sqrt(3/b),x)', isEqn=bool(1))

3) at the end of your document create the Latex file that you can then include (ex: \input{myEqns.tex}) in your master Latex document:

if (printArticle):
    fLATEX=open('myEqns.tex','w')
    fLATEX.write(latexPrint)
    fLATEX.close()
2017-01-25 18:27:44 +0100 commented answer How can I print equations just like latex?

Thanks, that's exactly what I was looking for! I changed the line html("$"+str+"$") to print "$"+str+"$" to get raw Latex from a Sage expression. Note that the print_expresion("6/(5*... line should read print_expression("6/(5*... with 2 s's. Also, for those interested: you can print the Latex code for an already defined symbolic equation by converting it to a string as print_expression(str(Lambda)) where Lambda is the name of your symbolic equation.

2017-01-25 14:45:43 +0100 commented answer latex Function Prevent Simplification

Not that I know of, but can see more discussion about this here: http://tex.stackexchange.com/question...

2016-12-19 10:38:39 +0100 commented answer Export to C code

Another comment @benjaminfjones : this line fs = f._sympy_() is really necessary ? I've noticed that even if I exclude it the conversion gets done and the code returned is identical... ANSWERING MY OWN COMMENT: yes sympy is necessary, in some cases I would get an error if not converting to sympy, so you can ignore my comment...

2016-12-01 12:11:17 +0100 received badge  Supporter (source)
2016-12-01 12:11:15 +0100 commented answer cancel one dict entry

Great! Didn't know the trick was so simple. Thanks. -Louis

2016-12-01 11:50:24 +0100 asked a question cancel one dict entry

Using sage notebook, is there a way to cancel an entry from an already defined dictionary without rewriting the whole dict ?

For example, let's say my sage worksheet goes as such:
soln = {}; # defining dictionary
soln[b] = 0.5
soln[c] = 0.2
soln[N] = 6;
etc. for many more soln entries

Then I do something which requires all values in soln, and after, I want to plot a function which uses all of soln values but one, say N. How can I cancel it ?

What I currently do is rerun my whole worksheet cell by cell after having commented the soln[N] = 6; line, but it takes more time than I'd like.

Thanks in advance!

2016-12-01 11:20:07 +0100 received badge  Self-Learner (source)
2016-12-01 11:20:07 +0100 received badge  Teacher (source)
2016-12-01 10:37:05 +0100 answered a question export notebook output to html

Thanks to both of you for your answers. I think however that what gets me as close as possible to what I want is the following:

  • Get the html directly from the source of the notebook output in the browser
    • find the output you are interested in, you can locate it by searching for the <script type="math/tex" portions
  • Paste it in your target html file
  • And link the MathJax script in your target html file by either

    • a) adding the following to your html file (ideally in the header): <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script>
    • b) getting the MathJax library and linking the local version of the script

More info on MathJax and the local/online versions can be found here: http://docs.mathjax.org/en/latest/ins... and here: http://docs.mathjax.org/en/latest/sta...

2016-11-30 10:04:52 +0100 commented answer export notebook output to html

@kcrisman thanks for your answer. It still doesn't quite do what I want. I've installed BeautifulSoup (not 4 because my version of --sws2rst did not recognize it) and did the whole procedure outlined in the tutorial, and tried it on different worksheets and with different rendering commands: print(), show(), pretty_print(), and view() but in all cases the equations don't appear in the final html document (nor in the rst doc). I get the commands rendered and the output rather shows each equation as: <html>...</html> Am I missing something? Thanks, -Louis

2016-11-18 21:54:28 +0100 received badge  Student (source)
2016-11-18 09:29:47 +0100 commented question export notebook output to html

@slelievre i've put the worksheet link in the comment above, thanks

2016-11-16 16:29:07 +0100 commented question export notebook output to html

its a sage worksheet by running http://localhost:8080/home/admin/, I know it is html, but as I mention in the question the equations do not appear in clear format at all (there are a bunch of calls in the header that refer to local scripts). Here is the worksheet: http://louisgagnon.com/transf/airfoilCenterOfMassClean.sws (http://louisgagnon.com/transf/airfoil...) and here is what I have done to export it manually: http://louisgagnon.com/scBlog/airfoilCenter.html (http://louisgagnon.com/scBlog/airfoil...)

2016-11-15 17:41:16 +0100 asked a question export notebook output to html

I've spent some hours looking for and trying out many different methods to achieve this, but it seems there is no simple way to get the whole output from an evaluated to html. Should I create a feature request ?

Here is what I've tried:

  • make one single pretty_print command and then using the MathML interface extract the code: works but it is impossible to do line breaks (they appear only as vertical displacements and the text then continues from the same horizontal position), and anyway it is not always easy to have all the output in one pretty_print statement
  • print to Latex: the code generated requires some fine tuning and then I would have to convert it to html anyway
  • copy the page source from the sagemath output: there is just too much clutter coming with it and the code obtained is not really MathML
  • put the %html comment at the beggining of the cell
  • etc.

So in the end I used the simple technique of copying and pasting individually each output from my cell's print commands into my html document and inserting the MathML from each pretty_print box's context menu one by one...

Is there a simpler way to generate a block of html from the entire content of an evaluated sagemath cell ?

If it can help I can post my Sagemath worksheet. Thanks and Regards, -Louis

2016-10-07 13:47:15 +0100 commented answer Export to C code

Thanks for this great solution. Just a detail, this line is also required before calling codegen: from sympy.utilities.codegen import codegen

2016-09-26 19:01:58 +0100 commented answer Automatic expression.maxima_methods().rootscontract() ?

Thanks, that solve my issue.