Questions tagged [l3fp]

Part of the LaTeX3 bundle to handle Floating-point operations

Filter by
Sorted by
Tagged with
6
votes
2answers
275 views

Checking if an integer is a member of an integer list

Is there any way to check whether an integer is a member of a list of integer numbers and return a boolean? I found this neat solution, here that does a great job. It checks whether a string exists ...
3
votes
2answers
201 views

Problems with numerical stability [closed]

In a macro that is supposed to calculate the value of the third derivative, I used the following formula: (f (x + 3 * delta) -3 * f (x + 2 * delta) + 3 * f (x + delta) -f (x)) / (delta) ^ 3 Because ...
5
votes
2answers
416 views

Input “x” instead of “#1”

Is there a possibility to have x instead of #1 for the name of the variable in the macro? I tried it with \regex_replace_all:nnN, but that did not work. Many thanks for your help. \documentclass{...
3
votes
1answer
133 views

How to use choice keys in l3?

I want to create some shortcuts for constants and I want to use these shortcuts for calculations (without units) for example with \fpeval with one or two different units I tried the following code, ...
6
votes
2answers
336 views

How to change the number of digits in the scientific notation in l3?

How can I change the number of digits in the scientific notation? \documentclass{article} \usepackage{xparse,siunitx} \begin{document} \ExplSyntaxOn \num{\fp_to_scientific:n { 3785*23 } } \...
3
votes
1answer
145 views

How to pass starred command to \fp_eval:n

I would like to define a command that has a starred version and pass it to \fp_eval:n for some calculations. However, regardless of whether I use the starred or the regular version, I get the error ...
4
votes
2answers
214 views

Integer and floating point accuracy in LaTeX3 [duplicate]

The L3fp package proposes the range of randint parameters to be +- 10^16 - 1; yet, I seem to be restricted to +-2^31 - 1, any value above it produces the Number too big compilation error. On the other ...
2
votes
1answer
176 views

Converting lengths with lengthconvert and l3fp

The package lengthconvert "uses the modul l3fp to convert the length". But its conversions are totally off the charts: \documentclass{article} \usepackage{lengthconvert} \begin{document} \the\...
4
votes
1answer
138 views

l3fp keeping trailing zero in math calc

I would like to keep the trailing zeros when the data, used for internal calculations with l3fp, are printed. For example: \documentclass{article} \usepackage{siunitx} \usepackage{expl3} \pagestyle{...
13
votes
2answers
2k views

Factorial (or, even better, binomial coefficient) function

Is there a function in l3fp for calculating factorials or, even better, binomial coefficients directly?
4
votes
1answer
798 views

l3fp “Number too big” error

Consider the following example: \documentclass{article} \usepackage{pstricks-add} \usepackage{expl3} \ExplSyntaxOn \cs_new_eq:NN \calc \fp_eval:n \ExplSyntaxOff \newcommand*\SideLength[1]{\calc{...
9
votes
1answer
346 views

Store results of a calculation automatically under a new macro name

As I am now accessing values from tables via a macro to make dynamic references in the text (see here) and make calculations with it, I need a way to make the resulting variables under which the ...
2
votes
1answer
477 views

Regular Expression for logical implication?

I am massively unfamiliar with the usage and syntax of regular expressions so the following problem is making my brain bleed. Background: I am taking logical expressions, parsing them, making some ...
4
votes
1answer
166 views

Symbolic functions: changing catcodes and \tl_rescan:nn

The goal is to have the user input (for the sake of argument) a linear function in one variable, for example 2*x+3 along with the variable (this isn't crucial) and a value for the variable. I would ...
11
votes
2answers
2k views

Iterative method to solve nonlinear equations

I am trying to solve the following equation (coming from fluid dynamics) using TeX. 1/sqrt(lambda) = 2 * log(Re * sqrt(lambda)) - 0.8 where lambda is the unknown, sqrt means "square root", the log ...
10
votes
1answer
2k views

How can I define NaN in LaTeX3

LaTeX3 l3fp offers a way to check if a variable has a an infinite value. The following code defines a number and then sets its value to π/2. It then calculates tan(π/2) to get a large result. \...