Skip to content

Commit

Permalink
Make is... and represents... function descriptions translatable; Do n…
Browse files Browse the repository at this point in the history
…ot translate hidden unit; Fix name properties for cal_IT and cal_th; Do not compare variable name with itself in comparison of exact and approximate value in calculate_dual_exact; Never return a solution for 1/f(x)=0 regardless of assumptions; Don not solve ln(f(x))=-infinity; Improve decision when to put number with scientific notation in parentheses; Return 0 in MathStructure::containsInfinity() if mathematical function returns true for representsFinite(); Update translations
  • Loading branch information
hanna-kn committed Jun 22, 2024
1 parent 9d82e23 commit d24c445
Show file tree
Hide file tree
Showing 25 changed files with 22,533 additions and 21,540 deletions.
73 changes: 73 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,76 @@
2024-06-22 Hanna Knutsson <[email protected]>

* Always return false for 1/f(x)=0 (not f(x)=infinity)
* Do not solve ln(f(x))=-infinity

2024-06-15 Hanna Knutsson <[email protected]>

* Add therm and thermie units (IT, ISO, and U.S.)
* Use exact Btu relation
* Use symbol "cal" for thermochemical (instead of international table) calorie
* Add IUNS calorie
* Fix input of scientific E-notation using lowercase e in numbers using concise interval notation, in expressions

2024-06-11 Hanna Knutsson <[email protected]>

* Always allow "ignore comma" option (will change default decimal separator if not dot), and show more informative error message for "ignore dot" if decimals separator is dot
* Do not mark decimal separator question as asked after percentage calculation has been asked

2024-06-10 Hanna Knutsson <[email protected]>

* Add MathStructure::representsFinite() to improve handling when unknown if value is real or complex
* Fix "bit width" and "signed integer" arguments in setbits()

2024-06-06 Hanna Knutsson <[email protected]>

* Preserve allow_infinite parameter for recursive comparison in MathStructure::equals()
* Return true for infinity multiplied by zero in MathStructure::representsUndefined()
* Add recursion counter to MathStructure::isolate_x() and MathStructure::isolate_x_sub() (variable isolation) to avoid stack overflow
* Return true both text strings are empty in equalsIgnoreCase()
* Fix parenthesis added in front of multiplication sign in some cases
* Use less strict rules when comparing with previous expression (to avoid infinite loop) when isolating variable, in MathStructure::isolate_x_sub(); * Do not apply x+x^(1/a)=b => x=(b-x)^a if (part of) x represents undefined

2024-06-05 Hanna Knutsson <[email protected]>

* Fix negative-size-param (crash) when a variable name/symbol with more than 20 characters is used in "where" expression
* Fix approximation mode changed with AUTOMATIC_APPROXIMATION_SINGLE in calculate_dual_exact (affects calculate-as-you-type in qalculate-qt)

2024-05-30 Hanna Knutsson <[email protected]>

* Update values of physical constants with CODATA 2022 values; Change title and names/symbols of weak mixing angle (prepend "sin2" to theta variants and change order)

2024-05-26 Hanna Knutsson <[email protected]>

* Return exact negative integers in log10()
* Decrease (potentially) number of false negatives for represents... functions
* Add descriptions for is... and represents... functions
* Fix RoundFunction::represents...
* Check for exact solution equaly simplified as approximation value in calculate_dual_exact when approximation is AUTOMATIC_APPROXIMATION_SINGLE
* Fix confusing behaviour of complex forms other than rectangular in some case with equalities and inequalities

2024-05-23 Hanna Knutsson <[email protected]>

* Remove n from equation solution if possible using assumptions of x
* Fix auto/dual approximation with "where" expression
* Fix Number::getCentralInteger()
* "n > a" equals "n >= floor(a)", if a is not an integer, and equivalent for other inequality operators
* Fix handling of where expressions with multiple inequality statements for a single variable, e.g. "where x>0 and x<10" (parsed expression were as aborted, and calculated value always 1)

2024-05-19 Hanna Knutsson <[email protected]>

* Fix potential (but unlikely) segfault when integrating expression with abs() and empty ln()
* Add allroots() function
* Fix unnecessary parenthesis (with wrong color for closing bracket) around unit with exponent for colorized HTML output (affects qalculate-qt)

2024-05-12 Hanna Knutsson <[email protected]>

* Add additional names/symbols (tr,pla,rev,revolution,revolutions,cyc,cycle,cycles) to turn unit
* Add rpm unit (= turns/min)

2024-05-10 Hanna Knutsson <[email protected]>

* Fix qalc not exiting after factorization in non-interactive mode

2024-05-06 Hanna Knutsson <[email protected]>

* Fix a^(f(x))=a^(b*g(x)) where b=2 or b=3
Expand Down
16 changes: 8 additions & 8 deletions data/functions.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -3299,31 +3299,31 @@
<builtin_function name="isNumber">
<_title>Is Number</_title>
<_names>r:isNumber</_names>
<description>Returns true if evaluated argument value is explicitely a real, complex, or infinite number (has number type).</description>
<_description>Returns true if evaluated argument value is explicitely a real, complex, or infinite number (has number type).</_description>
<argument index="1">
<_title>Value</_title>
</argument>
</builtin_function>
<builtin_function name="isReal">
<_title>Is Real</_title>
<_names>r:isReal</_names>
<description>Returns true if evaluated argument value is explicitely a real number (has number type with zero complex part).</description>
<_description>Returns true if evaluated argument value is explicitely a real number (has number type with zero complex part).</_description>
<argument index="1">
<_title>Value</_title>
</argument>
</builtin_function>
<builtin_function name="isRational">
<_title>Is Rational</_title>
<_names>r:isRational</_names>
<description>Returns true if evaluated argument value is explicitely a rational number (has rational type).</description>
<_description>Returns true if evaluated argument value is explicitely a rational number (has rational type).</_description>
<argument index="1">
<_title>Value</_title>
</argument>
</builtin_function>
<builtin_function name="isInteger">
<_title>Is Integer</_title>
<_names>r:isInteger</_names>
<description>Returns true if evaluated argument value is explicitely an integer (has integer type).</description>
<_description>Returns true if evaluated argument value is explicitely an integer (has integer type).</_description>
<example>$name(5 + 2) = 1; $name(x) = 0; $name(log(0.2, 5)) = 0</example>
<argument index="1">
<_title>Value</_title>
Expand All @@ -3332,31 +3332,31 @@
<builtin_function name="representsNumber">
<_title>Represents Number</_title>
<_names>r:representsNumber</_names>
<description>Returns true if value is or represents a number (scalar without unit). False negatives are allowed.</description>
<_description>Returns true if value is or represents a number (scalar without unit). False negatives are allowed.</_description>
<argument index="1">
<_title>Value</_title>
</argument>
</builtin_function>
<builtin_function name="representsReal">
<_title>Represents Real</_title>
<_names>r:representsReal</_names>
<description>Returns true if value is or represents a real number. False negatives are allowed.</description>
<_description>Returns true if value is or represents a real number. False negatives are allowed.</_description>
<argument index="1">
<_title>Value</_title>
</argument>
</builtin_function>
<builtin_function name="representsRational">
<_title>Represents Rational</_title>
<_names>r:representsRational</_names>
<description>Returns true if value is or represents a rational number. False negatives are allowed.</description>
<_description>Returns true if value is or represents a rational number. False negatives are allowed.</_description>
<argument index="1">
<_title>Value</_title>
</argument>
</builtin_function>
<builtin_function name="representsInteger">
<_title>Represents Integer</_title>
<_names>r:representsInteger</_names>
<description>Returns true if value is or represents an integer. False negatives are allowed.</description>
<_description>Returns true if value is or represents an integer. False negatives are allowed.</_description>
<example>$name(2n) = 1; $name(log(0.2, 5)) = 0</example>
<argument index="1">
<_title>Value</_title>
Expand Down
6 changes: 3 additions & 3 deletions data/units.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@
</unit>
<unit type="composite">
<hidden>true</hidden>
<_title>Revolutions per Minute</_title>
<title>Revolutions per Minute</title>
<names>r:turn_p_min</names>
<part>
<unit>turn</unit>
Expand Down Expand Up @@ -3720,7 +3720,7 @@
</unit>
<unit type="alias">
<_title>Calorie (international table)</_title>
<_names>ais:cal_IT</_names>
<_names>ars:cal_IT</_names>
<base>
<unit>J</unit>
<relation>4.1868</relation>
Expand All @@ -3729,7 +3729,7 @@
</unit>
<unit type="alias">
<_title>Calorie (thermochemical)</_title>
<_names>ars:cal_th,ar:cal,c:calorie,cp:calories</_names>
<_names>airs:cal_th,a:cal,c:calorie,cp:calories</_names>
<base>
<unit>J</unit>
<relation>4.184</relation>
Expand Down
5 changes: 1 addition & 4 deletions libqalculate/Calculator-calculate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ bool test_max_addition_size(const MathStructure &m, size_t n) {
bool equals_with_vname(const MathStructure &m1, const MathStructure &m2) {
if(m1.size() != m2.size() || m1.type() != m2.type()) return false;
if(m1.isVariable() && m2.isVariable()) {
if(m1.variable() == m2.variable() || m2.variable()->name() == m2.variable()->name()) return true;
if(m1.variable() == m2.variable() || m1.variable()->name() == m2.variable()->name()) return true;
return false;
}
if(m1.size() == 0) return m1.equals(m2, true, true);
Expand Down Expand Up @@ -1389,9 +1389,6 @@ void calculate_dual_exact(MathStructure &mstruct_exact, MathStructure *mstruct,
mstruct_exact.setUndefined();
} else if(auto_approx == AUTOMATIC_APPROXIMATION_SINGLE) {
mstruct_exact.setUndefined();
if(msecs > 0) CALCULATOR->stopControl();
CALCULATOR->endTemporaryStopMessages();
return;
}
if(mstruct_exact.containsType(STRUCT_COMPARISON)) {
bool b = false;
Expand Down
18 changes: 3 additions & 15 deletions libqalculate/MathStructure-isolatex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4456,21 +4456,8 @@ bool MathStructure::isolate_x_sub(const EvaluationOptions &eo, EvaluationOptions
bool b_nonzero = !CHILD(1).isZero() && CHILD(1).representsNonZero(true);
if(b_neg && CHILD(1).isZero()) {
if(ct_comp == COMPARISON_EQUALS || ct_comp == COMPARISON_NOT_EQUALS) {
if(CHILD(0)[0].representsFinite()) {
if(ct_comp == COMPARISON_EQUALS) clear(true);
else set(1, 1, 0, true);
return true;
}
CHILD(0).setToChild(1);
CHILD(1) = nr_plus_inf;
CHILDREN_UPDATED
MathStructure *malt = new MathStructure(*this);
(*malt)[1] = nr_minus_inf;
ComparisonType ct_comp_bak = ct_comp;
isolate_x_sub(eo, eo2, x_var, morig, depth + 1);
malt->isolate_x_sub(eo, eo2, x_var, morig, depth + 1);
add_nocopy(malt, ct_comp_bak == COMPARISON_NOT_EQUALS ? OPERATION_LOGICAL_AND : OPERATION_LOGICAL_OR);
calculatesub(eo, eo2, false);
if(ct_comp == COMPARISON_EQUALS) clear(true);
else set(1, 1, 0, true);
return true;
}
if(CHILD(0)[1].number().isInteger() && CHILD(0)[1].number().isEven()) {
Expand Down Expand Up @@ -5215,6 +5202,7 @@ bool MathStructure::isolate_x_sub(const EvaluationOptions &eo, EvaluationOptions
}
} else if(CHILD(0).function()->id() == FUNCTION_ID_LOG && CHILD(0).size() == 1) {
if(CHILD(0)[0].contains(x_var)) {
if(CHILD(1).isNumber() && CHILD(1).number().isMinusInfinity()) return false;
if(!CHILD(1).representsNonComplex()) {
if(ct_comp != COMPARISON_EQUALS && ct_comp != COMPARISON_NOT_EQUALS) return false;
MathStructure mtest(CALCULATOR->getVariableById(VARIABLE_ID_E));
Expand Down
7 changes: 3 additions & 4 deletions libqalculate/MathStructure-print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3859,7 +3859,6 @@ string MathStructure::print(const PrintOptions &po, bool format, int colorize, i
bool avoid_sign = (!po.short_multiplication && ips.power_depth > 0 && format && tagtype == TAG_TYPE_HTML && po.base >= 2 && po.base <= 10 && po.multiplication_sign == MULTIPLICATION_SIGN_X);
int i_sign = 0, i_sign_prev = 0;
bool wrap_next = false;
size_t prev_index = 0;
for(size_t i = 0; i < SIZE; i++) {
if(CALCULATOR->aborted()) return CALCULATOR->abortedMessage();
if(i == 0) ips_n.wrap = CHILD(i).needsParenthesis(po, ips_n, *this, i + 1, true, flat_power);
Expand Down Expand Up @@ -3938,12 +3937,12 @@ string MathStructure::print(const PrintOptions &po, bool format, int colorize, i
}
i--;
}
size_t l = print_str.length();
print_str += CHILD(i).print(po, format, b_units ? 0 : colorize, tagtype, ips_n);
if(i_sign_prev == MULTIPLICATION_SIGN_NONE && CHILD(i).isNumber() && (print_str.find_first_of("*^", prev_index) != string::npos || (po.use_unicode_signs && po.multiplication_sign == MULTIPLICATION_SIGN_DOT && print_str.find(SIGN_MULTIDOT, prev_index) != string::npos) || ((po.multiplication_sign == MULTIPLICATION_SIGN_DOT || po.multiplication_sign == MULTIPLICATION_SIGN_ALTDOT) && print_str.find(SIGN_MIDDLEDOT, prev_index) != string::npos) || (po.use_unicode_signs && po.multiplication_sign == MULTIPLICATION_SIGN_X && print_str.find(SIGN_MULTIPLICATION, prev_index) != string::npos))) {
print_str.insert(prev_index, "(");
if(((i > 0 && i_sign_prev == MULTIPLICATION_SIGN_NONE) || (i < SIZE - 1 && i_sign == MULTIPLICATION_SIGN_NONE)) && CHILD(i).isNumber() && (print_str.find_first_of("*^", l) != string::npos || (po.use_unicode_signs && po.multiplication_sign == MULTIPLICATION_SIGN_DOT && print_str.find(SIGN_MULTIDOT, l) != string::npos) || ((po.multiplication_sign == MULTIPLICATION_SIGN_DOT || po.multiplication_sign == MULTIPLICATION_SIGN_ALTDOT) && print_str.find(SIGN_MIDDLEDOT, l) != string::npos) || (po.use_unicode_signs && po.multiplication_sign == MULTIPLICATION_SIGN_X && print_str.find(SIGN_MULTIPLICATION, l) != string::npos))) {
print_str.insert(l, "(");
print_str += ")";
}
prev_index = print_str.length();
}
if(b_units && tagtype == TAG_TYPE_TERMINAL) print_str += "\033[0m";
else if(b_units && tagtype == TAG_TYPE_HTML) print_str += "</span>";
Expand Down
1 change: 1 addition & 0 deletions libqalculate/MathStructure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,7 @@ int MathStructure::containsInfinity(bool structural_only, bool check_variables,
if(function_value) {
return function_value->containsInfinity(structural_only, check_variables, check_functions);
}
if(representsFinite(true)) return 0;
return -1;
} else if(isAborted()) {
return -1;
Expand Down
Loading

0 comments on commit d24c445

Please sign in to comment.