simplifying expressions – Piecewise and Assumptions

Assumptions sometimes work as expected with Piecewise, for example

 Simplify[Piecewise[{{A, a + b >= c}, {B, True}}], Assumptions -> a + b > c]

correctly yields the symbol A.

But sometimes they do not work as expected, for example

 Simplify[Piecewise[{{A, a b + c d >= e f}, {B, True}}], Assumptions -> a b + c d > e f]

yields a Piecewise expression with both pieces even though the Assumptions clearly preclude B. Is there some way to help Simplify along in cases like this?

dnd 5e – Is there an issue with simplifying wealth rewards like this?

I’ve been playing for some years now, and with nearly all of my groups, keeping track of resources is always a hassle. To make things efficient, we basically eliminated all the multiple wealth levels and condensed into gold and gems.

A character gets 50cp, 11sp, 2g, a bracelet worth 25g, and a 50g diamond.

What my players write in their joint Bag of Holding inventory sheet is 27g + 50g (Gems). We eliminate the copper and silver right away, merge gold and jewelry, and don’t bother having to go to vendors in towns to haggle bracelets for gold, or gems, or whatever else. The gems are kept separately because they’re a compact way to transport large amounts of value, and because they’re common reagents (looking at you, Revivify! If a player is looking for specific gems as reagents, then those go to that character’s specific sheet).

Anyway, all these ways of tracking treasure, we need to simplify them. It’s hard for my players to keep track of ammunition, charges in magical items, rations/water (which we’ve already reduced as well, food is bought in units of rations), and a bunch of different units of treasure.

Is there any issues that can arise from simplifying the wealth rewards system like this?

simplifying expressions – How to reorganize a polynomial including exponents to the simplest form?

I want to reorganize a polynomial including exponents as the following Figure 1 to the form showing as Figure 2. Failed to realize it after several times trying such as Figure 3. Can you help me to get the result? Thank you.

Figure 1

enter image description here

Figure 2

enter image description here

or

enter image description here

Figure 3

enter image description here

Here are the codes:

In(12):= Solve(-1 + d - d E^-az + f(z)/f0 == 0, f(z))

Out(12)= {{f(z) -> -E^-az (-d - E^az + d E^az) f0}}

In(13):= -E^-az (-d - E^az + d E^az) f0 // Simplify

Out(13)= f0 + d (-1 + E^-az) f0

In(14):= FactorTerms(-E^-az (-d - E^az + d E^az) f0, f0)

Out(14)= f0 - d f0 + d E^-az f0

In(16):= Factor(-E^-az (-d - E^az + d E^az) f0)

Out(16)= -E^-az (-d - E^az + d E^az) f0

differential equations – Simplifying expression using asymptotic values of a function

I have a large expression with bessel function in the result of DSolve. The equation is

DSolve(3/2 (-2 + x) x (Alpha)^2 - y(x) + 2 Derivative(1)(y)(x) + 
   2 x (y^(Prime)(Prime))(x) == 0, {y(x)}, {x})

Now, I am only bothered with the large x value of the solution. We know, bessel functions have simplified behavior in the asymptotic limit, like

$I_n(x)=frac{e^x}{sqrt{2 pi x}}$.

Using this sort of simplified expressions, is it possible to reduce the result of DSolve using some predefined mathematica syntax? I am not able to do this using the “Series” command, as that gives a series with integer powers, and here, it may not be integers.

simplifying expressions – How to simplify for a ratio of two variables

Say I have an equation like

$$2 z ln(frac{a v_{2}^{2}}{b_{2}})+(v_{1}-2v_{2}) – z ln(frac{a v_{1}^{2}}{b_{1}})geq0$$

eq=2*z*Log(a*v2^2/b2)+(v1-2*v2)-z*Log(a*v1^2/b1)>=0 

I’d like to write this in terms of b2/b1

Which would be something like

$$frac{b_{2}}{b_{1}} leq frac{a v_{1}^{2}}{b_{2}a^{2}v_{2}^{4}}e^{v_{1}-2v{2}}$$

Note, that it hasn’t been solved for $frac{b_{2}}{b_{1}}$, there is still a $b_{2}$ on the right hand side.

Is it possible to ask Mathematica to simply for the ratio of some two variables? I have more complex expressions I’d like to simplify in this way.

simplifying expressions – Why Mathematica is not assuming real variable as real?

I am dealing with the situation where despite of specifying my variables b1 and c to be greater than zero, Mathematica still returns the output with Re(b1+c)

  In(1):= mat1 = Simplify(( {
     {a - ( b1 + c)/2 I, d},
     {d, a - (b2 - c )/2 I}
    } ));

mat2 = ( {
    {0, 0, 1, 0},
    {0, 0, 0, 1},
    {-1, 0, 0, 0},
    {0, -1, 0, 0}
   } );

MatrixForm(FullSimplify(( {
    {Re(mat1((1))((1))), 
     Re(mat1((1))((2))), -Im(mat1((1))((1))), -Im(mat1((1))((2)))},
    {Re(mat1((2))((1))), 
     Re(mat1((2))((2))), -Im(mat1((2))((1))), -Im(mat1((2))((2)))},
    {Im(mat1((1))((1))), Im(mat1((1))((2))), Re(mat1((1))((1))), 
     Re(mat1((1))((2)))},
    {Im(mat1((2))((1))), Im(mat1((2))((2))), Re(mat1((2))((1))), 
     Re(mat1((2))((2)))}
   } ), {a >= 0, d >= 0, b1 >= 0, b2 >= 0, c >= 0}))

Out(3)//MatrixForm= !(
TagBox(
RowBox({"(", "", GridBox({
{"a", "d", 
FractionBox(
RowBox({"b1", "+", "c"}), "2"), "0"},
{"d", "a", "0", 
FractionBox(
RowBox({"b2", "-", "c"}), "2")},
{
RowBox({
RowBox({"-", 
FractionBox("1", "2")}), " ", 
RowBox({"Re", "(", 
RowBox({"b1", "+", "c"}), ")"})}), "0", "a", "d"},
{"0", 
RowBox({
FractionBox("1", "2"), " ", 
RowBox({"(", 
RowBox({
RowBox({"-", "b2"}), "+", "c"}), ")"})}), "d", "a"}
},
GridBoxAlignment->{
      "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, 
       "Rows" -> {{Baseline}}, "RowsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset(0.27999999999999997`), {
Offset(0.7)}, 
Offset(0.27999999999999997`)}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset(0.2), {
Offset(0.4)}, 
Offset(0.2)}, "RowsIndexed" -> {}}), "", ")"}),
Function(BoxForm`e$, 
MatrixForm(BoxForm`e$))))

Trigonometry – How can I prevent Mathematica from simplifying basic trigonometric identities (1 / Cot (x))?

I am working on a code to display (Print ()) the answers of some exercises for my students. Some of the answers have parts like 1 / Cot (x). I want to prevent Mathematica from transforming this expression into Tan (x).

I tried (as another thread's suggestion)

Simplify(1/Cot(y), Trig -> False)

But it does not work. I also can't use Hold () because the expression refers to a previous calculation and I have to evaluate it. Advices ?? I have Mathematica 11.2 and forgive my English. Thank you!!

javascript – simplifying regex expression for timestamp

I was wondering if it’s possible to simplify this regex string (JS):

function validateDateString(date){
    const regex = /(0-1)(0-9)-(0-3)(0-9)-(0-9){4} (0-2)(0-9):(0-5)(0-9) (A|P)(M)/; 
    return regex.test(date)
}

It is supposed to validate a string in the following format: MM-DD-YYYY hh:mm A

javascript – Simplifying the array of objects with comma separated values

Looking a way to reduce the below code to get comma separated values from the list of arrays
By using ECMA or plain old vanilla JS. How should we achieve this?

Actual Array Data:

({
    ansBook: "046H",
    ansPersonId: "2044000102",
    bookNbr: "046H",
    dns: "0",
    examCode: "20717010",
    examShortTitle: "QA-ATAG-Director of Applications",
    nar: "0",
    personId: "2044000102",
    pull: "0",
    wn: "0",
    corrCd: 1
  },
  {
    ansBook: "046I",
    ansPersonId: "2044000102",
    bookNbr: "046I",
    dns: "0",
    examCode: "20721010",
    examShortTitle: "QA-ATAG-Plans Examinier",
    nar: "0",
    personId: "2044000102",
    pull: "0",
    wn: "0",
    corrCd: 1
  }
);

Expected Result:

{
  "PersonIds": "2044000102, 2044000102",
  "BookLetCodes": "046H, 046I",
  "ExamNumbers": "20717010, 20721010",
  "ExamTitles": "QA-ATAG-Director of Applications, QA-ATAG-Plans Examinier"
}

As I am getting the expected result. But I need to reduce and improvise the performance performed on it..

let seriesDataSet = ({
    ansBook: "046H",
    ansPersonId: "2044000102",
    bookNbr: "046H",
    dns: "0",
    examCode: "20717010",
    examShortTitle: "QA-ATAG-Director of Applications",
    nar: "0",
    personId: "2044000102",
    pull: "0",
    wn: "0",
    corrCd: 1
  },
  {
    ansBook: "046I",
    ansPersonId: "2044000102",
    bookNbr: "046I",
    dns: "0",
    examCode: "20721010",
    examShortTitle: "QA-ATAG-Plans Examinier",
    nar: "0",
    personId: "2044000102",
    pull: "0",
    wn: "0",
    corrCd: 1
  }
);

let auditingInfo = {};
auditingInfo = (seriesDataSet).filter(w => (w.dns == '0' && w.pull == '0') && w.corrCd == 1)
  .map(e => ({
    PersonIds: e.personId,
    BookLetCodes: e.ansBook,
    ExamNumbers: e.examCode,
    ExamTitles: e.examShortTitle
  }))
console.log(auditingInfo)

let auditingDetails = {
  PersonIds: auditingInfo.map(x => x.PersonIds).join(', '),
  BookLetCodes: auditingInfo.map(x => x.BookLetCodes).join(', '),
  ExamNumbers: auditingInfo.map(x => x.ExamNumbers).join(', '),
  ExamTitles: auditingInfo.map(x => x.ExamTitles).join(', ')
}
console.log('______________________________________________')
console.log('Expected Result:')
console.log(auditingDetails)
.as-console-wrapper {
  max-height: 100% !important;
  top: 0;
}

OR

let ScoringApprove: Array<number> = ();
ScoringApprove = new List<SeriesReportsDataset>(this.tempSeriesDataSet)
                .Where(w => (w.dns == '0' && w.pull == '0') && w.corrCd == 1)
                .Select(s => s.scannedResponseID).ToArray();

simplifying expressions – Split plus or minus into list

I would like

x= 2 (PlusMinus) Sqrt(3)

to evaluate to

{x=2+Sqrt(3),x=2-Sqrt(3)}

Including any number of plus or minus symbols, so

x=(2 (PlusMinus) Sqrt(3)) (PlusMinus) 3

would evaluation to

{x=5+Sqrt(3),x=5-Sqrt(3),x=-1+Sqrt(3),x=-1-Sqrt(3)}

Any ideas?

Thanks