Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
peterh is currently offline  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 Wink

Therefore this calculation is perfectly legal in physics. Wink



Again, many thanks,

Peter






[Updated on: Sat, 27 April 2019 20:16]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: OleAut : Office Automation Encapsulation, then made easy
Next Topic: MATLAB .mat files handling
Goto Forum:
  


Current Time: Thu Mar 28 19:52:02 CET 2024

Total time taken to generate the page: 0.01807 seconds