|
|
Home » Developing U++ » UppHub » New package MathTools
New package MathTools [message #45707] |
Sun, 27 December 2015 11:38 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Many times I see scientists and engineers using expensive over bloated tools like Matlab and Diadem for very simple issues. Even open source options like Scilab or Octave are big applications and some activities are not very evident, complex to be done.
New package MathTools includes simple math tools for scientists and engineers.
- Calculator is a text calculator that handles variables and some mathematical functions.
- Regression permits to paste numerical series and automatically searches for the equation that fits best.
These are utilities that I use frequently and I expect they could be useful for you.
Many improvements are possible always depending on the scarce time availability
If anybody may want to add new features, all of them and even new applications related with the subject will be acknowledged.
Best regards
Iñaki
|
|
|
Re: New package MathTools [message #45709 is a reply to message #45707] |
Sun, 27 December 2015 14:22 |
|
deep
Messages: 265 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hi Koldo,
I liked the concept.
I would like to add custom constants.
I tried to add it.
gridConstants.Add("DegToRad",M_PI/180.0);
Constants are not accessed for calculation from ArrayControl. It is internal to ScatterDraw/Equation.cpp
eval.constants.Add("DegToRad",M_PI/180.0);
'Upp::EvalExpr::constants': cannot access private member
declared in class 'Upp::EvalExpr'
After looking at the code the I found constants are defined in ScatterDraw/Equation.cpp
Any hints on how have custom constants.
Warm Regards
Deepak
[Updated on: Sun, 27 December 2015 15:00] Report message to a moderator
|
|
|
|
Re: New package MathTools [message #51629 is a reply to message #45710] |
Mon, 22 April 2019 12:19 |
|
peterh
Messages: 108 Registered: November 2018 Location: Germany
|
Experienced Member |
|
|
Hello I have a question about Mathtools:
It was initially my intention to tinker with it and add a "||" operator, which is really useful for electronics.
(Rp = R1*R2/(R1+R2) or Rp=1 /(1/R1 + 1/R2). If resistors are zero, then division by zero happens.)
When I input an expression in the calculator that divides by zero I get an exception.
When I restart the program, I cannot longer create variables.
This error persists even after I deleted Mathtools.json and even after rebooting.
I tried this on two different computers with the unmodified source and so I am pretty sure about this.
So the program must store some persistent data elsewhere. Where should I look?
I tried with the debugger but so far without success.
[Updated on: Mon, 22 April 2019 12:42] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: New package MathTools [message #51701 is a reply to message #51674] |
Sat, 27 April 2019 18:35 |
|
peterh
Messages: 108 Registered: November 2018 Location: Germany
|
Experienced Member |
|
|
Hi Koldo,
I modified the calculation a little bit:
void ResParallel(const doubleUnit &d) {
// if (val + d.val < 1e-100)
// throw Exc(t_("Division by zero"));
if (!(unit.IsEqual(d.unit) || IsNull(unit) || IsNull(d.unit)))
throw Exc(t_("Units does not match in resistor parallel"));
if (abs(val*d.val) < 1e-100)
val = 0.0;
else
if (abs(val + d.val) < 1e-100)
throw Exc(t_("Division by zero"));
val = val*d.val/(val + d.val);
}
It delivers now these results (which are correct):
1||1 = 0.5
1||0 = 0
0||0 = 0
-2||1 = 2
-1||2 = -2
-1||1 Error Division by zero
Please note, the "parallel" operator is not only useful for electronics.
There are many physic equations where this is useful.
For example, two elastic springs may have the elasticity konstants k1 and k2.
If the springs are in parallel then the total konstant is k1 + k2.
If the springs are in series then the total konstant is k1 || k2.
Some mathematicians might complain, that 0^2 / 0 = 0 is not allowed.
In physics this is allowed because the numbers have dimensions.
0^2 Ohm^2 is in a different dimension as 0^1 Ohm^1.
Ohm^2 and Ohm is as different as m^2 and m^1 and cannot been compared, added or subtracted.
The other point is: there is no absolute zero in physics, there is only zeropoint noise
Therefore this calculation is perfectly legal in physics.
Again, many thanks,
Peter
[Updated on: Sat, 27 April 2019 20:16] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 05:38:06 CEST 2024
Total time taken to generate the page: 0.05501 seconds
|
|
|