2
votes

Please look into attached file. I’m using Mathematica Solve function to solve some simple equations from physics. One of the equations is an If function which defines function value when a condition is met. Solve finds almost correct solution which itself is a ConditionalExpression. For independent variable θ = 90° the answer given by Solve is in error. It seems that Solve forgets the case when Cos equals 0. Why? Thanks.

Regards/Mikael Friction Model

2
mixing inherently symbolic operations Solve with a bunch of floating point values in the input should usually be avoided. Try this without specifying W,u and use Reduce instead of Solve - agentp

2 Answers

2
votes

Specifying theta as a real solves the problem.

w = 1500;
mus = 0.4;
fv = f Cos[theta Degree];
fh = f Sin[theta Degree];
fn = fv + w;
ff = If[mus fn >= 0, mus fn, 0];
frul = Quiet@Solve[fh == ff, f, Reals];
f /. frul /. theta -> 90.

{600.}

f /. frul /. theta -> 90

{Undefined}

Same again, with radians.

w = 1500;
mus = 0.4;
fv = f Cos[theta];
fh = f Sin[theta];
fn = fv + w;
ff = If[mus fn >= 0, mus fn, 0];
frul = Quiet@Solve[fh == ff, f, Reals];
f /. frul /. theta -> N[Pi/2]

{600.}

f /. frul /. theta -> Pi/2

{Undefined}

1
votes

Many thanks Chris.

Yes, giving it real numbers yields correct answers. This is because Cos[90.0°] is 6.123233995736766E-17 whereas Cos[90°] is 0. The solution is the same but we are fooling it with finite machine precision.

If I ask me, I would say that this is a bug in equation solver in Mathematica. The solution produced by Solve[] should test for Cos[] >= 0. Now it tests for Cos[] > 0 which is not true for Cos[90°].