Ask Your Question

geroyx's profile - activity

2020-11-12 02:00:18 -0600 received badge  Popular Question (source)
2020-10-21 11:20:48 -0600 commented answer How to get access of a single solution from a bunch of solutions

Ah, nice ;)

2020-10-21 07:12:04 -0600 asked a question How to get access of a single solution from a bunch of solutions

I do not use the thing for longer time, so I had a question.

If I say

a,b,c,d,e,x = var('a b c d e x')
f(x)=a*x^4+b*x^3+c*x^2+d*x+e
f1(x)=diff(f(x),x)
f2(x)=diff(f(x),x,2)
sols = solve([f(0)==-2, f(2)==0,  f1(4)==0, f(4)==8,  f2(2)==0], a,b,c,d,e)
print(sols)

I get

 [
[a == (3/16), b == (-41/16), c == (87/8), d == -12, e == -2]
]

How can I have these single value separately?
That means: I want to get an output f(x) = 3/16*x^4 -41/16*x^3 +87/8*x^2 -12*x -2
(which I can copy and paste).

2020-10-21 05:56:23 -0600 commented answer Plot the solution of a system of equations

TYVM. Helps me good. ;)

2020-10-21 05:07:25 -0600 asked a question Plot the solution of a system of equations

With

a,b,c,d,e,x = var('a b c d e x')
f(x)=a*x^4+b*x^3+c*x^2+d*x+e
f1(x)=diff(f(x),x)
f2(x)=diff(f(x),x,2)
solve([f(0)==-3, f(2)==0, f2(4)==0, f1(6)==0, f(6)==4], a,b,c,d,e)

I get [[a == (-7/432), b == (43/216), c == (-5/6), d == (5/2), e == -3]]

How can I plot f(x) with these values?

2020-09-21 04:29:27 -0600 received badge  Nice Question (source)
2020-09-21 04:29:21 -0600 received badge  Self-Learner (source)
2020-08-31 07:45:20 -0600 received badge  Popular Question (source)
2020-04-06 06:54:57 -0600 commented answer Syntax to define a Layout of a Plot

I have to use your code in the kind
Layout = dict(frame=False, axes_labels=['$k$','$B(k,{},{})$'.format(n,float(p))]) bar_chart([binom_dist.pmf(x) for x in range(n)], **Layout)

But this way it works.

2020-04-06 06:50:54 -0600 commented answer How to get a nice bar chart?

Very good, too. :()

2020-04-06 06:50:37 -0600 commented answer How to get a nice bar chart?

Very good. And yes, I note that as well. ;)

2020-04-06 06:02:48 -0600 commented answer Syntax to define a Layout of a Plot

Ah, very good! ;)

2020-04-06 05:39:04 -0600 commented answer How to plot the Binomial Distribution

Nice... ;)

2020-04-06 03:54:56 -0600 asked a question How to get a nice bar chart?

I have

image description

reset()
import scipy.stats
n = 2000
p = 0.2
binom_dist = scipy.stats.binom(n,p)
bar_chart([binom_dist.pmf(x) for x in range(n)], axes_labels=['$k$','$B(k,{},{})$'.format(n,float(p))])

How could I create something nicer, like

image description

2020-04-06 03:37:32 -0600 asked a question Syntax to define a Layout of a Plot

Just for interest:
I have

reset()
import scipy.stats
n = 2000
p = 0.2
binom_dist = scipy.stats.binom(n,p)
bar_chart([binom_dist.pmf(x) for x in range(n)], frame=True, axes_labels=['$k$','$B(k,{},{})$'.format(n,float(p))])

How could outsource the part like
Layout = frame=True, axes_labels=['$k$','$B(k,{},{})$'.format(n,float(p))]?

And then

bar_chart([binom_dist.pmf(x) for x in range(n)], Layout)
2020-04-05 12:47:23 -0600 asked a question How to plot the Binomial Distribution

Hey there, is there a macro for
image description
?

2020-01-16 18:36:32 -0600 received badge  Self-Learner (source)
2020-01-09 13:26:44 -0600 commented question Is there an inline command, that cleans the cache?

Probably it is reset()

2020-01-09 12:28:26 -0600 commented answer Correct way to get an exact number of decimal digits (after the point)

@dsejas OK, I understand. Seems your code has a little mistake. Suggestion:

def NumPrint(x, n):
    d = floor(log(abs(x), 10)) + 1
    return N(x, digits=n+d)#, d

print NumPrint(-100.25,2)
print NumPrint(1/14,7)
print NumPrint(0.0123, 4)
2020-01-07 08:27:04 -0600 commented question Max Min and Min Max

Your real question is probably: "How do I start / install Sage?"

Your other question: "How do I calculate the maximum of ...?" assumes the functioning of the first problem; and should then be in a separate thread; in particular, an example should be given for that second question.

2020-01-05 14:52:08 -0600 marked best answer SageTeX-Output: Possible simplification sought

I created a minimal example for SageTeX:

x = 420       # Denominator
MyRange = 222

M = []
for n in range (1,MyRange):
    if x == denominator(n/x):
        M.append('$' + latex(n/x).replace(' ','') + '$')
    else:
        M.append('$' + '\\frac{' + "{}".format(n) + '}{' + "{}".format(x) + '}=' + latex(n/x).replace(' ','') + '$')

MyOut = ', '.join(M)
print(MyOut)

This gives:

image description

It works! Just for interest, I wonder: does the 2nd else-output
M.append('$' + '\\frac{' + "{}".format(n) + '}{' + "{}".format(x) + '}=' + latex(n/x).replace(' ','') + '$')
really have to be so complicated or is there an easier way?

€dit: My SageTeX-MWE is:

\documentclass{article}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{sagetex}

\begin{document}
\section{In}
\begin{sageblock}
x = 420       # Denominator
MyRange = 222

M = []
for n in range (1,MyRange):
    if x == denominator(n/x):
        M.append('$' + latex(n/x).replace(' ','') + '$')
    else:
        M.append('$' + '\\frac{' + "{}".format(n) + '}{' + "{}".format(x) + '}=' + latex(n/x).replace(' ','') + '$')

MyOut = ', '.join(M)
#print MyOut
\end{sageblock}

\section{Out}
\baselineskip16pt \sagestr{MyOut}
\end{document}
2020-01-05 11:44:29 -0600 edited question Introduction: A shortcut for the compiling of SageTeX-files with arara

Note: This is a meta-post, so no answers are needed. I will answer it by myself.

My dearest SageTeXers, Sagers, arara-users and Pythoners as well!

The normal way to compile a file example.tex which contains SageTeX is

pdflatex example.tex
sage example.sagetex.sage
pdflatex example.tex

So the initial question is: How to make a shortcut for this?

2020-01-05 11:37:47 -0600 edited answer Introduction: A shortcut for the compiling of SageTeX-files with arara

If you use arara, known as "The cool TeX-automatisation Tool", written by @PauloCereda, you can set compilation instructions into your tex-document, i.e.
% arara: pdflatex
% arara: biber
.....
and then only one run arara example.tex is needed.

In TeXLive arara is installed by default. You can also integrate arara into your TeX editor.

There is no arara-rule for Sage in the main set of arara-rules, but it has been written:
See the original post arara: sage - A Sage(math)-rule for arara

It is sagetex.yaml, which works for Windows-users and for Linux-users:

!config
# SageTeX-Rule for arara.
#
# Dear Windows-users, please check the paths
# pathToBashExecutive    and    pathToSageStartfile
# due to your Sage-installation!
#
identifier: sagetex
name: SageTeX
authors:
- TeXnician (Author)
- cis (Idea)
arguments: []
commands:
- name: A SageTeX Rule for arara
  command: >
    @{
        pathToBashExecutive = "C:\\Programme\\SageMath8.9\\runtime\\bin\\bash";
        pathToSageStartfile = "C:/Programme/SageMath8.9/runtime/opt/sagemath-8.9/sage";
        pathOfCurrentWorkingFolder = currentFile().getParent();
        theWindowsCommand = getCommand(pathToBashExecutive, "-l", pathToSageStartfile, "-c", "os.chdir('" + pathOfCurrentWorkingFolder + "'); load('" + getBasename(currentFile()) + ".sagetex.sage')");
        return isWindows(theWindowsCommand, getCommand("sage", getBasename(file) + ".sagetex.sage"));
       }

Let's test an example.tex

% arara: pdflatex
% arara: sagetex
% arara: pdflatex

\documentclass{report} 
\usepackage{sagetex} 
\begin{document} 
\sage{2^1234} 
\end{document}