Echo input in output.
I'm trying to use sage for documentation purposes, and I'm looking for a way to do some of the following.
Enter an equation
f(x) = 2x
Input f(2)
or something close
and get back f(2) = 4
instead of just 4.
I'm also looking for a way to input
f(x) = 2x^2
Input diff(f(x),x), or an equivalent command and get
f'(x) = 4x
or d(f(x)/dx = 4x
.
And an icing on the cake would being able to input integrate(f(x)dx)
and return ∫f(x)dx => 4x + 15 + c
Bassically, if there is a way to the output more verbose, I'd love to know how.
I just started using Sage and I love it, thank you!
Edit: Thank you so much for the response @paulmasson Your word "typesetting" was new to me and helped me find some other posts.
https://ask.sagemath.org/question/30975/present-sage-output-as-normal-mathematics/ (This) seems to be my exact question:
https://ask.sagemath.org/question/7826/latex-typesetting-for-derivatives-like-g (This) one seemed to answer my question, but I don't know if I'm supposed to do this.
It gave me the idea of using f = function('f',x) == 2*x
I have no clue what function()
is, but I'm working on it.
I have no idea how or why this is different from f(x) = 2*x
, but it's pretty cool because now diff(f,x)
evaulates to d(f(x)/dy = 2
However, it doesn't do diff(f)
so well when there are two variables like f(x,y) = x^2 + y^2
.
I also really enjoyed this https://ask.sagemath.org/question/24039/showing-both-input-and-output/ (one):
Edit: Links, and I'm sorry to the moderator that has to keep approving my edits. Thank you for your time. I promise this will be my last edit.
I didn't realize myself that derivatives will now appear typeset if entered as fully symbolic functions, so you taught me something! As a former Mathematica user, I myself still don't quite get all the different ways Sage processes functions, symbolic or merely callable, so welcome to the club. That whole process could be made clearer.
P.S. if you put square brackets around the first URL in each pair and leave the parentheses around the second URL, they should the work like proper links for future readers.