Home » Developing U++ » UppHub » New package MathTools
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
|
|
|
|
|
New package MathTools
By: koldo on Sun, 27 December 2015 11:38
|
|
|
Re: New package MathTools
By: deep on Sun, 27 December 2015 14:22
|
|
|
Re: New package MathTools
By: koldo on Sun, 27 December 2015 20:54
|
|
|
Re: New package MathTools
By: peterh on Mon, 22 April 2019 12:19
|
|
|
Re: New package MathTools
By: koldo on Tue, 23 April 2019 09:35
|
|
|
Re: New package MathTools
By: peterh on Tue, 23 April 2019 10:47
|
|
|
Re: New package MathTools
By: koldo on Tue, 23 April 2019 11:43
|
|
|
Re: New package MathTools
By: peterh on Tue, 23 April 2019 12:11
|
|
|
Re: New package MathTools
By: koldo on Wed, 24 April 2019 07:29
|
|
|
Re: New package MathTools
By: peterh on Wed, 24 April 2019 10:31
|
|
|
Re: New package MathTools
By: peterh on Wed, 24 April 2019 13:29
|
|
|
Re: New package MathTools
By: peterh on Sat, 27 April 2019 18:35
|
|
|
Re: New package MathTools
By: koldo on Sat, 27 April 2019 22:12
|
|
|
Re: New package MathTools
By: peterh on Mon, 29 April 2019 08:46
|
Goto Forum:
Current Time: Thu Mar 28 19:52:02 CET 2024
Total time taken to generate the page: 0.01807 seconds
|